drm: Add mode object leases [v3]
Subsystems (10)
cover drm: Add mode object leases [v3]
Here's a third version of my DRM mode object leases series. Since v2:
* Add revocation. This allows leases to be effectively revoked by removing all of the objects they have access to. The lease itself hangs around as it's hanging off a file.
* Allow non-master files to look at all DRM mode objects. This lets the Vulkan code provide information about the display environment before the lease is created.
* Free the leases IDR when the master is destroyed. Just a bug fix.
* _drm_lease_held should look at lessees, not lessor. Just a bug fix.
I've also rebased it to a more recent version of Dave's drm-next branch.
With this and my CRTC-id based vblank series (posted separately), I'm now running "real" applications on a leased output and can fully support the following Vulkan extensions:
EXT_direct_mode_display
EXT_acquire_xlib_display
EXT_display_surface_counter
KEITHP_kms_display
-keith
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/6 drm: Pass struct drm_file * to __drm_mode_object_find
This will allow __drm_mode_object_file to be extended to perform access control checks based on the file in use.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 16 ++++++++-------- drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 4 ++-- drivers/gpu/drm/ast/ast_mode.c | 2 +- drivers/gpu/drm/bochs/bochs_kms.c | 2 +- drivers/gpu/drm/cirrus/cirrus_mode.c | 2 +- drivers/gpu/drm/drm_atomic.c | 8 ++++---- drivers/gpu/drm/drm_atomic_helper.c | 2 +- drivers/gpu/drm/drm_color_mgmt.c | 4 ++-- drivers/gpu/drm/drm_connector.c | 2 +- drivers/gpu/drm/drm_crtc.c | 8 ++++---- drivers/gpu/drm/drm_crtc_internal.h | 1 + drivers/gpu/drm/drm_encoder.c | 2 +- drivers/gpu/drm/drm_framebuffer.c | 9 +++++---- drivers/gpu/drm/drm_mode_object.c | 10 ++++++---- drivers/gpu/drm/drm_plane.c | 14 +++++++------- drivers/gpu/drm/drm_probe_helper.c | 2 +- drivers/gpu/drm/drm_property.c | 6 +++--- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 2 +- drivers/gpu/drm/i915/intel_display.c | 2 +- drivers/gpu/drm/i915/intel_overlay.c | 2 +- drivers/gpu/drm/i915/intel_sprite.c | 2 +- drivers/gpu/drm/mgag200/mgag200_mode.c | 2 +- drivers/gpu/drm/nouveau/nouveau_connector.c | 4 ++-- drivers/gpu/drm/radeon/r100.c | 2 +- drivers/gpu/drm/radeon/r600_cs.c | 2 +- drivers/gpu/drm/radeon/radeon_connectors.c | 16 ++++++++-------- drivers/gpu/drm/udl/udl_connector.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 +- include/drm/drm_connector.h | 3 ++- include/drm/drm_crtc.h | 5 +++-- include/drm/drm_encoder.h | 3 ++- include/drm/drm_framebuffer.h | 1 + include/drm/drm_mode_object.h | 2 ++ include/drm/drm_plane.h | 3 ++- include/drm/drm_property.h | 3 ++- 36 files changed, 84 insertions(+), 72 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +8 -8
@@ -231,7 +231,7 @@ amdgpu_connector_update_scratch_regs(struct drm_connector *connector,if (connector->encoder_ids[i] ==0 )break ; - encoder =drm_encoder_find (connector->dev, + encoder =drm_encoder_find (connector->dev,NULL , connector->encoder_ids[i]);if (!encoder)continue ;
@@ -256,7 +256,7 @@ amdgpu_connector_find_encoder(struct drm_connector *connector,for (i =0 ; i <DRM_CONNECTOR_MAX_ENCODER ; i++) {if (connector->encoder_ids[i] ==0 )break ; - encoder =drm_encoder_find (connector->dev, + encoder =drm_encoder_find (connector->dev,NULL , connector->encoder_ids[i]);if (!encoder)continue ;
@@ -374,7 +374,7 @@ amdgpu_connector_best_single_encoder(struct drm_connector *connector)/* pick the encoder ids */ if (enc_id) -return drm_encoder_find (connector->dev, enc_id); +return drm_encoder_find (connector->dev,NULL , enc_id);return NULL ; }
@@ -1079,7 +1079,7 @@ amdgpu_connector_dvi_detect(struct drm_connector *connector, bool force)if (connector->encoder_ids[i] ==0 )break ; - encoder =drm_encoder_find (connector->dev, connector->encoder_ids[i]); + encoder =drm_encoder_find (connector->dev,NULL , connector->encoder_ids[i]);if (!encoder)continue ;
@@ -1136,7 +1136,7 @@ amdgpu_connector_dvi_encoder(struct drm_connector *connector)if (connector->encoder_ids[i] ==0 )break ; - encoder =drm_encoder_find (connector->dev, connector->encoder_ids[i]); + encoder =drm_encoder_find (connector->dev,NULL , connector->encoder_ids[i]);if (!encoder)continue ;
@@ -1155,7 +1155,7 @@ amdgpu_connector_dvi_encoder(struct drm_connector *connector)/* then check use digitial */ /* pick the first one */ if (enc_id) -return drm_encoder_find (connector->dev, enc_id); +return drm_encoder_find (connector->dev,NULL , enc_id);return NULL ; }
@@ -1296,7 +1296,7 @@ u16 amdgpu_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector *connif (connector->encoder_ids[i] ==0 )break ; - encoder =drm_encoder_find (connector->dev, + encoder =drm_encoder_find (connector->dev,NULL , connector->encoder_ids[i]);if (!encoder)continue ;
@@ -1325,7 +1325,7 @@ static bool amdgpu_connector_encoder_is_hbr2(struct drm_connector *connector)for (i =0 ; i <DRM_CONNECTOR_MAX_ENCODER ; i++) {if (connector->encoder_ids[i] ==0 )break ; - encoder =drm_encoder_find (connector->dev, + encoder =drm_encoder_find (connector->dev,NULL , connector->encoder_ids[i]);if (!encoder)continue ;
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +2 -2
@@ -367,7 +367,7 @@ dce_virtual_encoder(struct drm_connector *connector)if (connector->encoder_ids[i] ==0 )break ; - encoder =drm_encoder_find (connector->dev, connector->encoder_ids[i]); + encoder =drm_encoder_find (connector->dev,NULL , connector->encoder_ids[i]);if (!encoder)continue ;
@@ -377,7 +377,7 @@ dce_virtual_encoder(struct drm_connector *connector)/* pick the first one */ if (enc_id) -return drm_encoder_find (connector->dev, enc_id); +return drm_encoder_find (connector->dev,NULL , enc_id);return NULL ; }
drivers/gpu/drm/ast/ast_mode.c +1 -1
@@ -711,7 +711,7 @@ static struct drm_encoder *ast_best_single_encoder(struct drm_connector *connectint enc_id = connector->encoder_ids[0 ];/* pick the encoder ids */ if (enc_id) -return drm_encoder_find (connector->dev, enc_id); +return drm_encoder_find (connector->dev,NULL , enc_id);return NULL ; }
drivers/gpu/drm/bochs/bochs_kms.c +1 -1
@@ -213,7 +213,7 @@ bochs_connector_best_encoder(struct drm_connector *connector)int enc_id = connector->encoder_ids[0 ];/* pick the encoder ids */ if (enc_id) -return drm_encoder_find (connector->dev, enc_id); +return drm_encoder_find (connector->dev,NULL , enc_id);return NULL ; }
drivers/gpu/drm/cirrus/cirrus_mode.c +1 -1
@@ -496,7 +496,7 @@ static struct drm_encoder *cirrus_connector_best_encoder(struct drm_connectorint enc_id = connector->encoder_ids[0 ];/* pick the encoder ids */ if (enc_id) -return drm_encoder_find (connector->dev, enc_id); +return drm_encoder_find (connector->dev,NULL , enc_id);return NULL ; }
drivers/gpu/drm/drm_atomic.c +4 -4
@@ -747,7 +747,7 @@ int drm_atomic_plane_set_property(struct drm_plane *plane,struct drm_mode_config *config = &dev->mode_config;if (property == config->prop_fb_id) { -struct drm_framebuffer *fb =drm_framebuffer_lookup (dev, val); +struct drm_framebuffer *fb =drm_framebuffer_lookup (dev,NULL , val);drm_atomic_set_fb_for_plane (state, fb);if (fb)drm_framebuffer_put (fb);
@@ -763,7 +763,7 @@ int drm_atomic_plane_set_property(struct drm_plane *plane,return -EINVAL ; }else if (property == config->prop_crtc_id) { -struct drm_crtc *crtc =drm_crtc_find (dev, val); +struct drm_crtc *crtc =drm_crtc_find (dev,NULL , val);return drm_atomic_set_crtc_for_plane (state, crtc); }else if (property == config->prop_crtc_x) { state->crtc_x =U642I64 (val);
@@ -1143,7 +1143,7 @@ int drm_atomic_connector_set_property(struct drm_connector *connector,struct drm_mode_config *config = &dev->mode_config;if (property == config->prop_crtc_id) { -struct drm_crtc *crtc =drm_crtc_find (dev, val); +struct drm_crtc *crtc =drm_crtc_find (dev,NULL , val);return drm_atomic_set_crtc_for_connector (state, crtc); }else if (property == config->dpms_property) {/* setting DPMS property requires special handling, which
@@ -2221,7 +2221,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, goto out; } - obj =drm_mode_object_find (dev, obj_id,DRM_MODE_OBJECT_ANY ); + obj =drm_mode_object_find (dev, file_priv, obj_id,DRM_MODE_OBJECT_ANY );if (!obj) { ret = -ENOENT ; goto out;
drivers/gpu/drm/drm_atomic_helper.c +1 -1
@@ -3145,7 +3145,7 @@ struct drm_encoder * drm_atomic_helper_best_encoder(struct drm_connector *connector) {WARN_ON (connector->encoder_ids[1 ]); -return drm_encoder_find (connector->dev, connector->encoder_ids[0 ]); +return drm_encoder_find (connector->dev,NULL , connector->encoder_ids[0 ]); }EXPORT_SYMBOL (drm_atomic_helper_best_encoder);
drivers/gpu/drm/drm_color_mgmt.c +2 -2
@@ -227,7 +227,7 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev,if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ; - crtc =drm_crtc_find (dev, crtc_lut->crtc_id); + crtc =drm_crtc_find (dev, file_priv, crtc_lut->crtc_id);if (!crtc)return -ENOENT ;
@@ -305,7 +305,7 @@ int drm_mode_gamma_get_ioctl(struct drm_device *dev,if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ; - crtc =drm_crtc_find (dev, crtc_lut->crtc_id); + crtc =drm_crtc_find (dev, file_priv, crtc_lut->crtc_id);if (!crtc)return -ENOENT ;
drivers/gpu/drm/drm_connector.c +1 -1
@@ -1289,7 +1289,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,memset (&u_mode,0 ,sizeof (struct drm_mode_modeinfo )); - connector =drm_connector_lookup (dev, out_resp->connector_id); + connector =drm_connector_lookup (dev, file_priv, out_resp->connector_id);if (!connector)return -ENOENT ;
drivers/gpu/drm/drm_crtc.c +4 -4
@@ -402,7 +402,7 @@ int drm_mode_getcrtc(struct drm_device *dev,if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ; - crtc =drm_crtc_find (dev, crtc_resp->crtc_id); + crtc =drm_crtc_find (dev, file_priv, crtc_resp->crtc_id);if (!crtc)return -ENOENT ;
@@ -569,7 +569,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,if (crtc_req->x &0xffff0000 || crtc_req->y &0xffff0000 )return -ERANGE ; - crtc =drm_crtc_find (dev, crtc_req->crtc_id); + crtc =drm_crtc_find (dev, file_priv, crtc_req->crtc_id);if (!crtc) {DRM_DEBUG_KMS ("Unknown CRTC ID %d\n" , crtc_req->crtc_id);return -ENOENT ;
@@ -595,7 +595,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,/* Make refcounting symmetric with the lookup path. */ drm_framebuffer_get (fb); }else { - fb =drm_framebuffer_lookup (dev, crtc_req->fb_id); + fb =drm_framebuffer_lookup (dev, file_priv, crtc_req->fb_id);if (!fb) {DRM_DEBUG_KMS ("Unknown FB ID%d\n" , crtc_req->fb_id);
@@ -680,7 +680,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, goto out; } - connector =drm_connector_lookup (dev, out_id); + connector =drm_connector_lookup (dev, file_priv, out_id);if (!connector) {DRM_DEBUG_KMS ("Connector id %d unknown\n" , out_id);
drivers/gpu/drm/drm_crtc_internal.h +1 -0
@@ -106,6 +106,7 @@ int drm_mode_object_add(struct drm_device *dev, struct drm_mode_object *obj,void drm_mode_object_register (struct drm_device *dev,struct drm_mode_object *obj);struct drm_mode_object *__drm_mode_object_find (struct drm_device *dev, +struct drm_file *file_priv,uint32_t id,uint32_t type);void drm_mode_object_unregister (struct drm_device *dev,struct drm_mode_object *object);
drivers/gpu/drm/drm_encoder.c +1 -1
@@ -220,7 +220,7 @@ int drm_mode_getencoder(struct drm_device *dev, void *data,if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ; - encoder =drm_encoder_find (dev, enc_resp->encoder_id); + encoder =drm_encoder_find (dev, file_priv, enc_resp->encoder_id);if (!encoder)return -ENOENT ;
drivers/gpu/drm/drm_framebuffer.c +5 -4
@@ -381,7 +381,7 @@ int drm_mode_rmfb(struct drm_device *dev,if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ; - fb =drm_framebuffer_lookup (dev, *id); + fb =drm_framebuffer_lookup (dev, file_priv, *id);if (!fb)return -ENOENT ;
@@ -450,7 +450,7 @@ int drm_mode_getfb(struct drm_device *dev,if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ; - fb =drm_framebuffer_lookup (dev, r->fb_id); + fb =drm_framebuffer_lookup (dev, file_priv, r->fb_id);if (!fb)return -ENOENT ;
@@ -515,7 +515,7 @@ int drm_mode_dirtyfb_ioctl(struct drm_device *dev,if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ; - fb =drm_framebuffer_lookup (dev, r->fb_id); + fb =drm_framebuffer_lookup (dev, file_priv, r->fb_id);if (!fb)return -ENOENT ;
@@ -688,12 +688,13 @@ EXPORT_SYMBOL(drm_framebuffer_init);* again, using drm_framebuffer_put(). */ struct drm_framebuffer *drm_framebuffer_lookup (struct drm_device *dev, +struct drm_file *file_priv,uint32_t id) {struct drm_mode_object *obj;struct drm_framebuffer *fb =NULL ; - obj =__drm_mode_object_find (dev, id,DRM_MODE_OBJECT_FB ); + obj =__drm_mode_object_find (dev, file_priv, id,DRM_MODE_OBJECT_FB );if (obj) fb =obj_to_fb (obj);return fb;
drivers/gpu/drm/drm_mode_object.c +6 -4
@@ -105,6 +105,7 @@ void drm_mode_object_unregister(struct drm_device *dev, }struct drm_mode_object *__drm_mode_object_find (struct drm_device *dev, +struct drm_file *file_priv,uint32_t id,uint32_t type) {struct drm_mode_object *obj =NULL ;
@@ -127,7 +128,7 @@ struct drm_mode_object *__drm_mode_object_find(struct drm_device *dev,/** * drm_mode_object_find - look up a drm object with static lifetime -* @dev: drm device +* @file_priv: drm file * @id: id of the mode object * @type: type of the mode object *
@@ -136,11 +137,12 @@ struct drm_mode_object *__drm_mode_object_find(struct drm_device *dev,* by callind drm_mode_object_put(). */ struct drm_mode_object *drm_mode_object_find (struct drm_device *dev, +struct drm_file *file_priv,uint32_t id,uint32_t type) {struct drm_mode_object *obj =NULL ; - obj =__drm_mode_object_find (dev, id, type); + obj =__drm_mode_object_find (dev, file_priv, id, type);return obj; }EXPORT_SYMBOL (drm_mode_object_find);
@@ -347,7 +349,7 @@ int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,drm_modeset_lock_all (dev); - obj =drm_mode_object_find (dev, arg->obj_id, arg->obj_type); + obj =drm_mode_object_find (dev, file_priv, arg->obj_id, arg->obj_type);if (!obj) { ret = -ENOENT ; goto out;
@@ -395,7 +397,7 @@ int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,drm_modeset_lock_all (dev); - arg_obj =drm_mode_object_find (dev, arg->obj_id, arg->obj_type); + arg_obj =drm_mode_object_find (dev, file_priv, arg->obj_id, arg->obj_type);if (!arg_obj) { ret = -ENOENT ; goto out;
drivers/gpu/drm/drm_plane.c +7 -7
@@ -395,7 +395,7 @@ int drm_mode_getplane(struct drm_device *dev, void *data,if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ; - plane =drm_plane_find (dev, plane_resp->plane_id); + plane =drm_plane_find (dev, file_priv, plane_resp->plane_id);if (!plane)return -ENOENT ;
@@ -584,7 +584,7 @@ int drm_mode_setplane(struct drm_device *dev, void *data,* First, find the plane, crtc, and fb objects. If not available, * we don't bother to call the driver. */ - plane =drm_plane_find (dev, plane_req->plane_id); + plane =drm_plane_find (dev, file_priv, plane_req->plane_id);if (!plane) {DRM_DEBUG_KMS ("Unknown plane ID %d\n" , plane_req->plane_id);
@@ -592,14 +592,14 @@ int drm_mode_setplane(struct drm_device *dev, void *data, }if (plane_req->fb_id) { - fb =drm_framebuffer_lookup (dev, plane_req->fb_id); + fb =drm_framebuffer_lookup (dev, file_priv, plane_req->fb_id);if (!fb) {DRM_DEBUG_KMS ("Unknown framebuffer ID %d\n" , plane_req->fb_id);return -ENOENT ; } - crtc =drm_crtc_find (dev, plane_req->crtc_id); + crtc =drm_crtc_find (dev, file_priv, plane_req->crtc_id);if (!crtc) {DRM_DEBUG_KMS ("Unknown crtc ID %d\n" , plane_req->crtc_id);
@@ -709,7 +709,7 @@ static int drm_mode_cursor_common(struct drm_device *dev,if (!req->flags || (~DRM_MODE_CURSOR_FLAGS & req->flags))return -EINVAL ; - crtc =drm_crtc_find (dev, req->crtc_id); + crtc =drm_crtc_find (dev, file_priv, req->crtc_id);if (!crtc) {DRM_DEBUG_KMS ("Unknown CRTC ID %d\n" , req->crtc_id);return -ENOENT ;
@@ -823,7 +823,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,if ((page_flip->flags &DRM_MODE_PAGE_FLIP_ASYNC ) && !dev->mode_config.async_page_flip)return -EINVAL ; - crtc =drm_crtc_find (dev, page_flip->crtc_id); + crtc =drm_crtc_find (dev, file_priv, page_flip->crtc_id);if (!crtc)return -ENOENT ;
@@ -884,7 +884,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, goto out; } - fb =drm_framebuffer_lookup (dev, page_flip->fb_id); + fb =drm_framebuffer_lookup (dev, file_priv, page_flip->fb_id);if (!fb) { ret = -ENOENT ; goto out;
drivers/gpu/drm/drm_probe_helper.c +1 -1
@@ -99,7 +99,7 @@ drm_mode_validate_pipeline(struct drm_display_mode *mode,/* Step 2: Validate against encoders and crtcs */ for (i =0 ; i <DRM_CONNECTOR_MAX_ENCODER ; i++) { -struct drm_encoder *encoder =drm_encoder_find (dev, ids[i]); +struct drm_encoder *encoder =drm_encoder_find (dev,NULL , ids[i]);struct drm_crtc *crtc;if (!encoder)
drivers/gpu/drm/drm_property.c +3 -3
@@ -450,7 +450,7 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ; - property =drm_property_find (dev, out_resp->prop_id); + property =drm_property_find (dev, file_priv, out_resp->prop_id);if (!property)return -ENOENT ;
@@ -634,7 +634,7 @@ struct drm_property_blob *drm_property_lookup_blob(struct drm_device *dev,struct drm_mode_object *obj;struct drm_property_blob *blob =NULL ; - obj =__drm_mode_object_find (dev, id,DRM_MODE_OBJECT_BLOB ); + obj =__drm_mode_object_find (dev,NULL , id,DRM_MODE_OBJECT_BLOB );if (obj) blob =obj_to_blob (obj);return blob;
@@ -874,7 +874,7 @@ bool drm_property_change_valid_get(struct drm_property *property,if (value ==0 )return true; - *ref =__drm_mode_object_find (property->dev, value, + *ref =__drm_mode_object_find (property->dev,NULL , value, property->values[0 ]);return *ref !=NULL ; }
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c +1 -1
@@ -36,7 +36,7 @@ static int hibmc_connector_mode_valid(struct drm_connector *connector,static struct drm_encoder *hibmc_connector_best_encoder (struct drm_connector *connector) { -return drm_encoder_find (connector->dev, connector->encoder_ids[0 ]); +return drm_encoder_find (connector->dev,NULL , connector->encoder_ids[0 ]); } static const struct drm_connector_helper_funcs
drivers/gpu/drm/i915/intel_display.c +1 -1
@@ -14027,7 +14027,7 @@ int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,struct drm_crtc *drmmode_crtc;struct intel_crtc *crtc; - drmmode_crtc =drm_crtc_find (dev, pipe_from_crtc_id->crtc_id); + drmmode_crtc =drm_crtc_find (dev, file, pipe_from_crtc_id->crtc_id);if (!drmmode_crtc)return -ENOENT ;
drivers/gpu/drm/i915/intel_overlay.c +1 -1
@@ -1128,7 +1128,7 @@ int intel_overlay_put_image_ioctl(struct drm_device *dev, void *data,if (!params)return -ENOMEM ; - drmmode_crtc =drm_crtc_find (dev, put_image_rec->crtc_id); + drmmode_crtc =drm_crtc_find (dev, file_priv, put_image_rec->crtc_id);if (!drmmode_crtc) { ret = -ENOENT ; goto out_free;
drivers/gpu/drm/i915/intel_sprite.c +1 -1
@@ -974,7 +974,7 @@ int intel_sprite_set_colorkey(struct drm_device *dev, void *data, set->flags & I915_SET_COLORKEY_DESTINATION)return -EINVAL ; - plane =drm_plane_find (dev, set->plane_id); + plane =drm_plane_find (dev, file_priv, set->plane_id);if (!plane || plane->type !=DRM_PLANE_TYPE_OVERLAY )return -ENOENT ;
drivers/gpu/drm/mgag200/mgag200_mode.c +1 -1
@@ -1695,7 +1695,7 @@ static struct drm_encoder *mga_connector_best_encoder(struct drm_connectorint enc_id = connector->encoder_ids[0 ];/* pick the encoder ids */ if (enc_id) -return drm_encoder_find (connector->dev, enc_id); +return drm_encoder_find (connector->dev,NULL , enc_id);return NULL ; }
drivers/gpu/drm/nouveau/nouveau_connector.c +2 -2
@@ -373,7 +373,7 @@ find_encoder(struct drm_connector *connector, int type)if (!id)break ; - enc =drm_encoder_find (dev, id); + enc =drm_encoder_find (dev,NULL , id);if (!enc)continue ; nv_encoder =nouveau_encoder (enc);
@@ -441,7 +441,7 @@ nouveau_connector_ddc_detect(struct drm_connector *connector)if (id ==0 )break ; - encoder =drm_encoder_find (dev, id); + encoder =drm_encoder_find (dev,NULL , id);if (!encoder)continue ; nv_encoder =nouveau_encoder (encoder);
drivers/gpu/drm/radeon/r100.c +1 -1
@@ -1456,7 +1456,7 @@ int r100_cs_packet_parse_vline(struct radeon_cs_parser *p) header =radeon_get_ib_value (p, h_idx); crtc_id =radeon_get_ib_value (p, h_idx +5 ); reg =R100_CP_PACKET0_GET_REG (header); - crtc =drm_crtc_find (p->rdev->ddev, crtc_id); + crtc =drm_crtc_find (p->rdev->ddev, p->filp, crtc_id);if (!crtc) {DRM_ERROR ("cannot find crtc %d\n" , crtc_id);return -ENOENT ;
drivers/gpu/drm/radeon/r600_cs.c +1 -1
@@ -887,7 +887,7 @@ int r600_cs_common_vline_parse(struct radeon_cs_parser *p, crtc_id =radeon_get_ib_value (p, h_idx +2 +7 +1 ); reg =R600_CP_PACKET0_GET_REG (header); - crtc =drm_crtc_find (p->rdev->ddev, crtc_id); + crtc =drm_crtc_find (p->rdev->ddev, p->filp, crtc_id);if (!crtc) {DRM_ERROR ("cannot find crtc %d\n" , crtc_id);return -ENOENT ;
drivers/gpu/drm/radeon/radeon_connectors.c +8 -8
@@ -263,7 +263,7 @@ radeon_connector_update_scratch_regs(struct drm_connector *connector, enum drm_cif (connector->encoder_ids[i] ==0 )break ; - encoder =drm_encoder_find (connector->dev, + encoder =drm_encoder_find (connector->dev,NULL , connector->encoder_ids[i]);if (!encoder)continue ;
@@ -290,7 +290,7 @@ static struct drm_encoder *radeon_find_encoder(struct drm_connector *connector,if (connector->encoder_ids[i] ==0 )break ; - encoder =drm_encoder_find (connector->dev, connector->encoder_ids[i]); + encoder =drm_encoder_find (connector->dev,NULL , connector->encoder_ids[i]);if (!encoder)continue ;
@@ -404,7 +404,7 @@ static struct drm_encoder *radeon_best_single_encoder(struct drm_connector *connint enc_id = connector->encoder_ids[0 ];/* pick the encoder ids */ if (enc_id) -return drm_encoder_find (connector->dev, enc_id); +return drm_encoder_find (connector->dev,NULL , enc_id);return NULL ; }
@@ -1365,7 +1365,7 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)if (connector->encoder_ids[i] ==0 )break ; - encoder =drm_encoder_find (connector->dev, + encoder =drm_encoder_find (connector->dev,NULL , connector->encoder_ids[i]);if (!encoder)continue ;
@@ -1451,7 +1451,7 @@ static struct drm_encoder *radeon_dvi_encoder(struct drm_connector *connector)if (connector->encoder_ids[i] ==0 )break ; - encoder =drm_encoder_find (connector->dev, connector->encoder_ids[i]); + encoder =drm_encoder_find (connector->dev,NULL , connector->encoder_ids[i]);if (!encoder)continue ;
@@ -1470,7 +1470,7 @@ static struct drm_encoder *radeon_dvi_encoder(struct drm_connector *connector)/* then check use digitial */ /* pick the first one */ if (enc_id) -return drm_encoder_find (connector->dev, enc_id); +return drm_encoder_find (connector->dev,NULL , enc_id);return NULL ; }
@@ -1617,7 +1617,7 @@ u16 radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector *connif (connector->encoder_ids[i] ==0 )break ; - encoder =drm_encoder_find (connector->dev, connector->encoder_ids[i]); + encoder =drm_encoder_find (connector->dev,NULL , connector->encoder_ids[i]);if (!encoder)continue ;
@@ -1646,7 +1646,7 @@ static bool radeon_connector_encoder_is_hbr2(struct drm_connector *connector)if (connector->encoder_ids[i] ==0 )break ; - encoder =drm_encoder_find (connector->dev, connector->encoder_ids[i]); + encoder =drm_encoder_find (connector->dev,NULL , connector->encoder_ids[i]);if (!encoder)continue ;
drivers/gpu/drm/udl/udl_connector.c +1 -1
@@ -105,7 +105,7 @@ static struct drm_encoder* udl_best_single_encoder(struct drm_connector *connector) {int enc_id = connector->encoder_ids[0 ]; -return drm_encoder_find (connector->dev, enc_id); +return drm_encoder_find (connector->dev,NULL , enc_id); } static int udl_connector_set_property(struct drm_connector *connector,
drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c +2 -2
@@ -286,7 +286,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,drm_modeset_lock_all (dev); - fb =drm_framebuffer_lookup (dev, arg->fb_id); + fb =drm_framebuffer_lookup (dev, file_priv, arg->fb_id);if (!fb) {DRM_ERROR ("Invalid framebuffer id.\n" ); ret = -ENOENT ;
@@ -369,7 +369,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,drm_modeset_lock_all (dev); - fb =drm_framebuffer_lookup (dev, arg->fb_id); + fb =drm_framebuffer_lookup (dev, file_priv, arg->fb_id);if (!fb) {DRM_ERROR ("Invalid framebuffer id.\n" ); ret = -ENOENT ;
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +1 -1
@@ -1811,7 +1811,7 @@ int vmw_kms_cursor_bypass_ioctl(struct drm_device *dev, void *data,return 0 ; } - crtc =drm_crtc_find (dev, arg->crtc_id); + crtc =drm_crtc_find (dev, file_priv, arg->crtc_id);if (!crtc) { ret = -ENOENT ; goto out;
include/drm/drm_connector.h +2 -1
@@ -903,10 +903,11 @@ static inline unsigned drm_connector_index(struct drm_connector *connector)* add takes a reference to it. */ static inline struct drm_connector *drm_connector_lookup (struct drm_device *dev, +struct drm_file *file_priv,uint32_t id) {struct drm_mode_object *mo; - mo =drm_mode_object_find (dev, id,DRM_MODE_OBJECT_CONNECTOR ); + mo =drm_mode_object_find (dev, file_priv, id,DRM_MODE_OBJECT_CONNECTOR );return mo ?obj_to_connector (mo) :NULL ; }
include/drm/drm_crtc.h +3 -2
@@ -951,10 +951,11 @@ struct drm_crtc *drm_crtc_from_index(struct drm_device *dev, int idx);* userspace interface should be done using &drm_property. */ static inline struct drm_crtc *drm_crtc_find (struct drm_device *dev, -uint32_t id) +struct drm_file *file_priv, +uint32_t id) {struct drm_mode_object *mo; - mo =drm_mode_object_find (dev, id,DRM_MODE_OBJECT_CRTC ); + mo =drm_mode_object_find (dev, file_priv, id,DRM_MODE_OBJECT_CRTC );return mo ?obj_to_crtc (mo) :NULL ; }
include/drm/drm_encoder.h +2 -1
@@ -214,11 +214,12 @@ static inline bool drm_encoder_crtc_ok(struct drm_encoder *encoder,* drm_mode_object_find(). */ static inline struct drm_encoder *drm_encoder_find (struct drm_device *dev, +struct drm_file *file_priv,uint32_t id) {struct drm_mode_object *mo; - mo =drm_mode_object_find (dev, id,DRM_MODE_OBJECT_ENCODER ); + mo =drm_mode_object_find (dev, file_priv, id,DRM_MODE_OBJECT_ENCODER );return mo ?obj_to_encoder (mo) :NULL ; }
include/drm/drm_framebuffer.h +1 -0
@@ -198,6 +198,7 @@ int drm_framebuffer_init(struct drm_device *dev,struct drm_framebuffer *fb, const struct drm_framebuffer_funcs *funcs);struct drm_framebuffer *drm_framebuffer_lookup (struct drm_device *dev, +struct drm_file *file_priv,uint32_t id);void drm_framebuffer_remove (struct drm_framebuffer *fb);void drm_framebuffer_cleanup (struct drm_framebuffer *fb);
include/drm/drm_mode_object.h +2 -0
@@ -27,6 +27,7 @@struct drm_object_properties ;struct drm_property ;struct drm_device ; +struct drm_file ;/** * struct drm_mode_object - base structure for modeset objects
@@ -113,6 +114,7 @@ struct drm_object_properties { }struct drm_mode_object *drm_mode_object_find (struct drm_device *dev, +struct drm_file *file_priv,uint32_t id,uint32_t type);void drm_mode_object_get (struct drm_mode_object *obj);void drm_mode_object_put (struct drm_mode_object *obj);
include/drm/drm_plane.h +2 -1
@@ -571,10 +571,11 @@ int drm_mode_plane_set_obj_prop(struct drm_plane *plane,* drm_mode_object_find(). */ static inline struct drm_plane *drm_plane_find (struct drm_device *dev, +struct drm_file *file_priv,uint32_t id) {struct drm_mode_object *mo; - mo =drm_mode_object_find (dev, id,DRM_MODE_OBJECT_PLANE ); + mo =drm_mode_object_find (dev, file_priv, id,DRM_MODE_OBJECT_PLANE );return mo ?obj_to_plane (mo) :NULL ; }
include/drm/drm_property.h +2 -1
@@ -310,10 +310,11 @@ drm_property_unreference_blob(struct drm_property_blob *blob)* This function looks up the property object specified by id and returns it. */ static inline struct drm_property *drm_property_find (struct drm_device *dev, +struct drm_file *file_priv,uint32_t id) {struct drm_mode_object *mo; - mo =drm_mode_object_find (dev, id,DRM_MODE_OBJECT_PROPERTY ); + mo =drm_mode_object_find (dev, file_priv, id,DRM_MODE_OBJECT_PROPERTY );return mo ?obj_to_property (mo) :NULL ; }
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/6 drm: Allow render nodes to query display objects
In reply to Keith PackardThis allows an application to discover what display resources are available before requesting a lease from the X server.
--- drivers/gpu/drm/drm_ioctl.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_ioctl.c +10 -10
@@ -613,27 +613,27 @@ static const struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_GEM_FLINK , drm_gem_flink_ioctl,DRM_AUTH |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_GEM_OPEN , drm_gem_open_ioctl,DRM_AUTH |DRM_UNLOCKED ), -DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETRESOURCES , drm_mode_getresources,DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETRESOURCES , drm_mode_getresources,DRM_RENDER_ALLOW |DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_PRIME_HANDLE_TO_FD , drm_prime_handle_to_fd_ioctl,DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF (DRM_IOCTL_PRIME_FD_TO_HANDLE , drm_prime_fd_to_handle_ioctl,DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ), -DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETPLANERESOURCES , drm_mode_getplane_res,DRM_CONTROL_ALLOW |DRM_UNLOCKED ), -DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETCRTC , drm_mode_getcrtc,DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETPLANERESOURCES , drm_mode_getplane_res,DRM_RENDER_ALLOW |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETCRTC , drm_mode_getcrtc,DRM_RENDER_ALLOW |DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_SETCRTC , drm_mode_setcrtc,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), -DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETPLANE , drm_mode_getplane,DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETPLANE , drm_mode_getplane,DRM_RENDER_ALLOW |DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_SETPLANE , drm_mode_setplane,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_CURSOR , drm_mode_cursor_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETGAMMA , drm_mode_gamma_get_ioctl,DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_SETGAMMA , drm_mode_gamma_set_ioctl,DRM_MASTER |DRM_UNLOCKED ), -DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETENCODER , drm_mode_getencoder,DRM_CONTROL_ALLOW |DRM_UNLOCKED ), -DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETCONNECTOR , drm_mode_getconnector,DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETENCODER , drm_mode_getencoder,DRM_RENDER_ALLOW |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETCONNECTOR , drm_mode_getconnector,DRM_RENDER_ALLOW |DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_ATTACHMODE , drm_noop,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_DETACHMODE , drm_noop,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), -DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETPROPERTY , drm_mode_getproperty_ioctl,DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETPROPERTY , drm_mode_getproperty_ioctl,DRM_RENDER_ALLOW |DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_SETPROPERTY , drm_mode_connector_property_set_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), -DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETPROPBLOB , drm_mode_getblob_ioctl,DRM_CONTROL_ALLOW |DRM_UNLOCKED ), -DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETFB , drm_mode_getfb,DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETPROPBLOB , drm_mode_getblob_ioctl,DRM_RENDER_ALLOW |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETFB , drm_mode_getfb,DRM_RENDER_ALLOW |DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_ADDFB , drm_mode_addfb,DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_ADDFB2 , drm_mode_addfb2,DRM_CONTROL_ALLOW |DRM_UNLOCKED ), DRM_IOCTL_DEF(DRM_IOCTL_MODE_RMFB, drm_mode_rmfb, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
@@ -642,7 +642,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_MODE_CREATE_DUMB , drm_mode_create_dumb_ioctl,DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_MAP_DUMB , drm_mode_mmap_dumb_ioctl,DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_DESTROY_DUMB , drm_mode_destroy_dumb_ioctl,DRM_CONTROL_ALLOW |DRM_UNLOCKED ), -DRM_IOCTL_DEF (DRM_IOCTL_MODE_OBJ_GETPROPERTIES , drm_mode_obj_get_properties_ioctl,DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_OBJ_GETPROPERTIES , drm_mode_obj_get_properties_ioctl,DRM_RENDER_ALLOW |DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_OBJ_SETPROPERTY , drm_mode_obj_set_property_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_CURSOR2 , drm_mode_cursor2_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), DRM_IOCTL_DEF(DRM_IOCTL_MODE_ATOMIC, drm_mode_atomic_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/6 drm: Add new LEASE debug level
In reply to Keith PackardSeparate out lease debugging from the core.
--- drivers/gpu/drm/drm_drv.c | 3 ++- include/drm/drmP.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_drv.c +2 -1
@@ -57,7 +57,8 @@ MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug cat"\t\tBit 2 (0x04) will enable KMS messages (modesetting code)\n" "\t\tBit 3 (0x08) will enable PRIME messages (prime code)\n" "\t\tBit 4 (0x10) will enable ATOMIC messages (atomic code)\n" -"\t\tBit 5 (0x20) will enable VBL messages (vblank code)"); +"\t\tBit 5 (0x20) will enable VBL messages (vblank code)\n" +"\t\tBit 7 (0x80) will enable LEASE messages (leasing code)");module_param_named (debug, drm_debug, int,0600 );static DEFINE_SPINLOCK (drm_minor_lock);
include/drm/drmP.h +4 -0
@@ -145,6 +145,7 @@ struct pci_controller;#define DRM_UT_ATOMIC 0x10#define DRM_UT_VBL 0x20#define DRM_UT_STATE 0x40 +#define DRM_UT_LEASE 0x80/***********************************************************************/ /** \name DRM template customization defaults */
@@ -259,6 +260,9 @@ struct pci_controller;#define DRM_DEBUG_VBL (fmt, ...) \ drm_printk(KERN_DEBUG, DRM_UT_VBL, fmt, ##__VA_ARGS__) +#define DRM_DEBUG_LEASE (fmt, ...) \ + drm_printk(KERN_DEBUG, DRM_UT_LEASE, fmt, ##__VA_ARGS__) + #define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, level, fmt, args...) \ ({ \ static DEFINE_RATELIMIT_STATE(_rs, \
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/6 drm: Add drm_object lease infrastructure [v3]
In reply to Keith PackardThis provides new data structures to hold "lease" information about drm mode setting objects, and provides for creating new drm_masters which have access to a subset of the available drm resources.
An 'owner' is a drm_master which is not leasing the objects from another drm_master, and hence 'owns' them.
A 'lessee' is a drm_master which is leasing objects from some other drm_master. Each lessee holds the set of objects which it is leasing from the lessor.
A 'lessor' is a drm_master which is leasing objects to another drm_master. This is the same as the owner in the current code.
The set of objects any drm_master 'controls' is limited to the set of objects it leases (for lessees) or all objects (for owners).
Objects not controlled by a drm_master cannot be modified through the various state manipulating ioctls, and any state reported back to user space will be edited to make them appear idle and/or unusable. For instance, connectors always report 'disconnected', while encoders report no possible crtcs or clones.
The full list of lessees leasing objects from an owner (either directly, or indirectly through another lessee), can be searched from an idr in the drm_master of the owner.
Changes for v2 as suggested by Daniel Vetter <[email protected]>:
* Sub-leasing has been disabled.
* BUG_ON for lock checking replaced with lockdep_assert_held
* 'change' ioctl has been removed.
* Leased objects can always be controlled by the lessor; the 'mask_lease' flag has been removed
* Checking for leased status has been simplified, replacing the drm_lease_check function with drm_lease_held.
Changes in v3, some suggested by Dave Airlie <[email protected]>
* Add revocation. This allows leases to be effectively revoked by removing all of the objects they have access to. The lease itself hangs around as it's hanging off a file.
* Free the leases IDR when the master is destroyed
* _drm_lease_held should look at lessees, not lessor
* Allow non-master files to check for lease status
--- drivers/gpu/drm/Makefile | 2 +- drivers/gpu/drm/drm_auth.c | 29 +++- drivers/gpu/drm/drm_lease.c | 376 ++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_auth.h | 20 +++ include/drm/drm_lease.h | 36 ++++ include/drm/drm_mode_object.h | 1 + 6 files changed, 462 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/drm_lease.c create mode 100644 include/drm/drm_lease.h
drivers/gpu/drm/Makefile +1 -1
@@ -17,7 +17,7 @@ drm-y := drm_auth.o drm_bufs.o drm_cache.o \ drm_encoder.o drm_mode_object.o drm_property.o \ drm_plane.o drm_color_mgmt.o drm_print.o \ drm_dumb_buffers.o drm_mode_config.o drm_vblank.o \ - drm_syncobj.o + drm_syncobj.o drm_lease.o drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o drm-$(CONFIG_DRM_VM) += drm_vm.o
drivers/gpu/drm/drm_auth.c +28 -1
@@ -31,6 +31,7 @@#include <drm/drmP.h> #include "drm_internal.h" #include "drm_legacy.h" +#include <drm/drm_lease.h> /** * DOC: master and authentication
@@ -93,7 +94,7 @@ int drm_authmagic(struct drm_device *dev, void *data,return file ?0 : -EINVAL ; } -static struct drm_master *drm_master_create (struct drm_device *dev) +struct drm_master *drm_master_create (struct drm_device *dev) {struct drm_master *master;
@@ -107,6 +108,14 @@ static struct drm_master *drm_master_create(struct drm_device *dev)idr_init (&master->magic_map); master->dev = dev; +/* initialize the tree of output resource lessees */ + master->lessor =NULL ; + master->lessee_id =0 ; +INIT_LIST_HEAD (&master->lessees); +INIT_LIST_HEAD (&master->lessee_list); +idr_init (&master->leases); +idr_init (&master->lessee_idr); +return master; }
@@ -189,6 +198,12 @@ int drm_setmaster_ioctl(struct drm_device *dev, void *data, goto out_unlock; } +if (file_priv->master->lessor !=NULL ) { +DRM_DEBUG_LEASE ("Attempt to set lessee %d as master\n" , file_priv->master->lessee_id); + ret = -EINVAL ; + goto out_unlock; + } + ret =drm_set_master (dev, file_priv, false); out_unlock:mutex_unlock (&dev->master_mutex);
@@ -270,6 +285,13 @@ void drm_master_release(struct drm_file *file_priv)if (dev->master == file_priv->master)drm_drop_master (dev, file_priv); out: +if (file_priv->is_master) { +/* Revoke any leases held by this or lessees, but only if +* this is the "real" master +*/ +_drm_lease_revoke (master); + } +/* drop the master reference held by the file priv */ if (file_priv->master)drm_master_put (&file_priv->master);
@@ -310,12 +332,17 @@ static void drm_master_destroy(struct kref *kref) struct drm_master *master = container_of(kref, struct drm_master, refcount);struct drm_device *dev = master->dev; +drm_lease_destroy (master); +if (dev->driver->master_destroy) dev->driver->master_destroy (dev, master);drm_legacy_master_rmmaps (dev, master);idr_destroy (&master->magic_map); +idr_destroy (&master->leases); +idr_destroy (&master->lessee_idr); +kfree (master->unique);kfree (master); }
drivers/gpu/drm/drm_lease.c new file +376 -0
376 lines not on this page · raw message
include/drm/drm_auth.h +20 -0
@@ -52,6 +52,12 @@ struct drm_lock_data {* @dev: Link back to the DRM device * @lock: DRI1 lock information. * @driver_priv: Pointer to driver-private information. +* @lessor: Lease holder +* @lessee_id: id for lessees. Owners always have id 0 +* @lessee_list: other lessees of the same master +* @lessees: drm_masters leasing from this one +* @leases: Objects leased to this drm_master. +* @lessee_idr: All lessees under this owner (only used where lessor == NULL) * * Note that master structures are only relevant for the legacy/primary device * nodes, hence there can only be one per device, not one per drm_minor.
@@ -76,10 +82,24 @@ struct drm_master {struct idr magic_map;struct drm_lock_data lock;void *driver_priv; + +/* Tree of display resource leases, each of which is a drm_master struct +* All of these get activated simultaneously, so drm_device master points +* at the top of the tree (for which lessor is NULL) +*/ + +struct drm_master *lessor; +int lessee_id; +struct list_head lessee_list; +struct list_head lessees; +struct idr leases; + struct idr lessee_idr; };struct drm_master *drm_master_get (struct drm_master *master);void drm_master_put (struct drm_master **master);bool drm_is_current_master (struct drm_file *fpriv); +struct drm_master *drm_master_create (struct drm_device *dev); +#endif
include/drm/drm_lease.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Copyright © 2017 Keith Packard <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +*/ + +#ifndef _DRM_LEASE_H_ +#define _DRM_LEASE_H_ + +struct drm_file ; +struct drm_device ; +struct drm_master ; + +struct drm_master *drm_lease_owner (struct drm_master *master); + +void drm_lease_destroy (struct drm_master *lessee); + +bool drm_lease_held (struct drm_file *file_priv,int id); + +bool _drm_lease_held (struct drm_file *file_priv,int id); + +void _drm_lease_revoke (struct drm_master *master); + +uint32_t drm_lease_filter_crtcs (struct drm_file *file_priv,uint32_t crtcs); + +uint32_t drm_lease_filter_encoders (struct drm_file *file_priv,uint32_t encoders); + +#endif /* _DRM_LEASE_H_ */
include/drm/drm_mode_object.h +1 -0
@@ -24,6 +24,7 @@#define __DRM_MODESET_H__#include <linux/kref.h> +#include <drm/drm_lease.h> struct drm_object_properties ;struct drm_property ;struct drm_device ;
Signature · 1 line
2.11.0
Dave Airlie
maintainerRe: [PATCH 4/6] drm: Add drm_object lease infrastructure [v3]
Quoted 4 lines
+ *
+ *drm_masterat the top of the tree (i.e, with lessor NULL
+ */
+structdrm_master*drm_lease_owner(structdrm_master*master) {
^ there's a couple of misplaced braces around. start of next line please.
Quoted 24 lines
drivers/gpu/drm/drm_lease.c new file +24
-0+while (master->lessor !=NULL ) + master = master->lessor; +return master; +} +EXPORT_SYMBOL (drm_lease_owner); + +/** +* _drm_find_lessee - find lessee by id +* @master: drm_master of lessor +* @id: lessee_id +* +* RETURN: +* +* drm_master of the lessee if valid, NULL otherwise +*/ + +static struct drm_master * +_drm_find_lessee (struct drm_master *master,int lessee_id) +{ +return idr_find (&drm_lease_owner (master)->lessee_idr, lessee_id); +} + +/** +* _drm_lease_held_master - check to see if an object is leased (or owned) by master
drivers/gpu/drm/drm_lease.c line 68
Quoted 10 lines
drivers/gpu/drm/drm_lease.c new file +10
-0+* @master: the master to check the lease status of +* @id: the id to check +* +* Checks if the specified master holds a lease on the object. Return +* value: +* +* true 'master' holds a lease on (or owns) the object +* false 'master' does not hold a lease. +*/ +static int _drm_lease_held_master (struct drm_master *master,int id) {
^^ here as well.
Quoted 8 lines
drivers/gpu/drm/drm_lease.c new file +8
-0+lockdep_assert_held (&master->dev->mode_config.idr_mutex); +if (master->lessor) +return idr_find (&master->leases, id) !=NULL ; +return true; +} + +/** +* _drm_has_leased - check to see if an object has been leased
drivers/gpu/drm/drm_lease.c line 86
Quoted 10 lines
drivers/gpu/drm/drm_lease.c new file +10
-0+* @master: the master to check the lease status of +* @id: the id to check +* +* Checks if any lessee of 'master' holds a lease on 'id'. Return +* value: +* +* true Some lessee holds a lease on the object. +* false No lessee has a lease on the object. +*/ +static bool _drm_has_leased (struct drm_master *master,int id) {
^^ here as well
Quoted 23 lines
drivers/gpu/drm/drm_lease.c new file +23
-0+} +EXPORT_SYMBOL (drm_lease_held); + +/** +* drm_lease_filter_crtcs - restricted crtc set to leased values +* @file_priv: requestor file +* @crtcs: bitmask of crtcs to check +* +* Reconstructs a crtc mask based on the crtcs which are visible +* through the specified file. +*/ +uint32_t drm_lease_filter_crtcs (struct drm_file *file_priv,uint32_t crtcs_in) +{ +struct drm_master *master; +struct drm_device *dev; +struct drm_crtc *crtc; +int count_in, count_out; +uint32_t crtcs_out =0 ; + +if (file_priv ==NULL || file_priv->master ==NULL ) +return crtcs_in; + + master = file_priv->master;
drivers/gpu/drm/drm_lease.c line 171
Quoted 10 lines
drivers/gpu/drm/drm_lease.c new file +10
-0+ dev = master->dev; + + count_in = count_out =0 ; +mutex_lock (&master->dev->mode_config.idr_mutex); +list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) { +if (_drm_lease_held_master (master, crtc->base.id)) { +uint32_t mask_in =1ul << count_in; +if ((crtcs_in & mask_in) !=0 ) { +uint32_t mask_out =1ul << count_out; + crtcs_out |= mask_out;
There are a couple of stray tab chars in here ^
drivers/gpu/drm/drm_lease.c line 211
Quoted 7 lines
drivers/gpu/drm/drm_lease.c new file +7
-0+mutex_lock (&master->dev->mode_config.idr_mutex); +list_for_each_entry (encoder, &dev->mode_config.encoder_list, head) { +if (_drm_lease_held_master (master, encoder->base.id)) { +uint32_t mask_in =1ul << count_in; +if ((encoders_in & mask_in) !=0 ) { +uint32_t mask_out =1ul << count_out; + encoders_out |= mask_out;
And here ^
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/6 drm: Check mode object lease status in all master ioctl paths [v2]
In reply to Keith PackardAttempts to modify un-leased objects are rejected with an error. Information returned about unleased objects is modified to make them appear unusable and/or disconnected.
Changes for v2 as suggested by Daniel Vetter <[email protected]>:
With the change in the __drm_mode_object_find API to pass the file_priv along, we can now centralize most of the lease-based access checks in that function.
A few places skip that API and require in-line checks.
--- drivers/gpu/drm/drm_auth.c | 2 +- drivers/gpu/drm/drm_connector.c | 5 +++-- drivers/gpu/drm/drm_encoder.c | 8 +++++--- drivers/gpu/drm/drm_mode_config.c | 32 +++++++++++++++++++------------- drivers/gpu/drm/drm_mode_object.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/drm_plane.c | 8 +++++--- drivers/gpu/drm/drm_vblank.c | 18 ++++++++++++++++-- 7 files changed, 71 insertions(+), 24 deletions(-)
drivers/gpu/drm/drm_auth.c +1 -1
@@ -310,7 +310,7 @@ void drm_master_release(struct drm_file *file_priv)*/ bool drm_is_current_master (struct drm_file *fpriv) { -return fpriv->is_master && fpriv->master == fpriv->minor->dev->master; +return fpriv->is_master &&drm_lease_owner (fpriv->master) == fpriv->minor->dev->master; }EXPORT_SYMBOL (drm_is_current_master);
drivers/gpu/drm/drm_connector.c +3 -2
@@ -1295,7 +1295,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,drm_modeset_lock (&dev->mode_config.connection_mutex,NULL ); encoder =drm_connector_get_encoder (connector); -if (encoder) +if (encoder &&drm_lease_held (file_priv, encoder->base.id)) out_resp->encoder_id = encoder->base.id;else out_resp->encoder_id =0 ;
@@ -1309,7 +1309,8 @@ int drm_mode_getconnector(struct drm_device *dev, void *data, goto out_unref;for (i =0 ; i <DRM_CONNECTOR_MAX_ENCODER ; i++) -if (connector->encoder_ids[i] !=0 ) +if (connector->encoder_ids[i] !=0 && +drm_lease_held (file_priv, connector->encoder_ids[i])) encoders_count++;if ((out_resp->count_encoders >= encoders_count) && encoders_count) {
drivers/gpu/drm/drm_encoder.c +5 -3
@@ -226,7 +226,7 @@ int drm_mode_getencoder(struct drm_device *dev, void *data,drm_modeset_lock (&dev->mode_config.connection_mutex,NULL ); crtc =drm_encoder_get_crtc (encoder); -if (crtc) +if (crtc &&drm_lease_held (file_priv, crtc->base.id)) enc_resp->crtc_id = crtc->base.id;else enc_resp->crtc_id =0 ;
@@ -234,8 +234,10 @@ int drm_mode_getencoder(struct drm_device *dev, void *data, enc_resp->encoder_type = encoder->encoder_type; enc_resp->encoder_id = encoder->base.id; - enc_resp->possible_crtcs = encoder->possible_crtcs; - enc_resp->possible_clones = encoder->possible_clones; + enc_resp->possible_crtcs =drm_lease_filter_crtcs (file_priv, + encoder->possible_crtcs); + enc_resp->possible_clones =drm_lease_filter_encoders (file_priv, + encoder->possible_clones);return 0 ; }
drivers/gpu/drm/drm_mode_config.c +19 -13
@@ -122,20 +122,24 @@ int drm_mode_getresources(struct drm_device *dev, void *data, count =0 ; crtc_id =u64_to_user_ptr (card_res->crtc_id_ptr);drm_for_each_crtc (crtc, dev) { -if (count < card_res->count_crtcs && -put_user (crtc->base.id, crtc_id + count)) -return -EFAULT ; - count++; +if (drm_lease_held (file_priv, crtc->base.id)) { +if (count < card_res->count_crtcs && +put_user (crtc->base.id, crtc_id + count)) +return -EFAULT ; + count++; + } } card_res->count_crtcs = count; count =0 ; encoder_id =u64_to_user_ptr (card_res->encoder_id_ptr);drm_for_each_encoder (encoder, dev) { -if (count < card_res->count_encoders && -put_user (encoder->base.id, encoder_id + count)) -return -EFAULT ; - count++; +if (drm_lease_held (file_priv, encoder->base.id)) { +if (count < card_res->count_encoders && +put_user (encoder->base.id, encoder_id + count)) +return -EFAULT ; + count++; + } } card_res->count_encoders = count;
@@ -143,12 +147,14 @@ int drm_mode_getresources(struct drm_device *dev, void *data, count =0 ; connector_id =u64_to_user_ptr (card_res->connector_id_ptr);drm_for_each_connector_iter (connector, &conn_iter) { -if (count < card_res->count_connectors && -put_user (connector->base.id, connector_id + count)) { -drm_connector_list_iter_end (&conn_iter); -return -EFAULT ; +if (drm_lease_held (file_priv, connector->base.id)) { +if (count < card_res->count_connectors && +put_user (connector->base.id, connector_id + count)) { +drm_connector_list_iter_end (&conn_iter); +return -EFAULT ; + } + count++; } - count++; } card_res->count_connectors = count;drm_connector_list_iter_end (&conn_iter);
drivers/gpu/drm/drm_mode_object.c +22 -0
@@ -104,6 +104,25 @@ void drm_mode_object_unregister(struct drm_device *dev,mutex_unlock (&dev->mode_config.idr_mutex); } +/** +* drm_lease_required - check types which must be leased to be used +* @type: type of object +* +* Returns whether the provided type of drm_mode_object must +* be owned or leased to be used by a process. +*/ +static bool drm_lease_required (uint32_t type) +{ +switch (type) { +case DRM_MODE_OBJECT_CRTC : +case DRM_MODE_OBJECT_CONNECTOR : +case DRM_MODE_OBJECT_ENCODER : +return true; +default : +return false; + } +} +struct drm_mode_object *__drm_mode_object_find (struct drm_device *dev,struct drm_file *file_priv,uint32_t id,uint32_t type)
@@ -117,6 +136,9 @@ struct drm_mode_object *__drm_mode_object_find(struct drm_device *dev,if (obj && obj->id != id) obj =NULL ; +if (obj &&drm_lease_required (obj->type) && !_drm_lease_held (file_priv, obj->id)) + obj =NULL ; +if (obj && obj->free_cb) {if (!kref_get_unless_zero (&obj->refcount)) obj =NULL ;
drivers/gpu/drm/drm_plane.c +5 -3
@@ -400,9 +400,9 @@ int drm_mode_getplane(struct drm_device *dev, void *data,return -ENOENT ;drm_modeset_lock (&plane->mutex,NULL ); -if (plane->state && plane->state->crtc) +if (plane->state && plane->state->crtc &&drm_lease_held (file_priv, plane->state->crtc->base.id)) plane_resp->crtc_id = plane->state->crtc->base.id; -else if (!plane->state && plane->crtc) +else if (!plane->state && plane->crtc &&drm_lease_held (file_priv, plane->crtc->base.id)) plane_resp->crtc_id = plane->crtc->base.id;else plane_resp->crtc_id =0 ;
@@ -416,7 +416,9 @@ int drm_mode_getplane(struct drm_device *dev, void *data,drm_modeset_unlock (&plane->mutex); plane_resp->plane_id = plane->base.id; - plane_resp->possible_crtcs = plane->possible_crtcs; + plane_resp->possible_crtcs =drm_lease_filter_crtcs (file_priv, + plane->possible_crtcs); + plane_resp->gamma_size =0 ;/*
drivers/gpu/drm/drm_vblank.c +16 -2
@@ -1436,9 +1436,11 @@ static bool drm_wait_vblank_is_query(union drm_wait_vblank *vblwait)int drm_wait_vblank (struct drm_device *dev,void *data,struct drm_file *file_priv) { +struct drm_crtc *crtc;struct drm_vblank_crtc *vblank;union drm_wait_vblank *vblwait = data;int ret; +unsigned int pipe_index;unsigned int flags, seq, pipe, high_pipe;if (!dev->irq_enabled)
@@ -1460,9 +1462,21 @@ int drm_wait_vblank(struct drm_device *dev, void *data, flags = vblwait->request.type & _DRM_VBLANK_FLAGS_MASK; high_pipe = (vblwait->request.type & _DRM_VBLANK_HIGH_CRTC_MASK);if (high_pipe) - pipe = high_pipe >> _DRM_VBLANK_HIGH_CRTC_SHIFT; + pipe_index = high_pipe >> _DRM_VBLANK_HIGH_CRTC_SHIFT;else - pipe = flags & _DRM_VBLANK_SECONDARY ?1 :0 ; + pipe_index = flags & _DRM_VBLANK_SECONDARY ?1 :0 ; + +/* Convert lease-relative crtc index into global crtc index */ + pipe =0 ; +drm_for_each_crtc (crtc, dev) { +if (drm_lease_held (file_priv, crtc->base.id)) { +if (pipe_index ==0 ) +break ; + pipe_index--; + } + pipe++; + } +if (pipe >= dev->num_crtcs)return -EINVAL ;
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/6 drm: Add four ioctls for managing drm mode object leases [v3]
In reply to Keith Packarddrm_mode_create_lease
Creates a lease for a list of drm mode objects, returning an fd for the new drm_master and a 64-bit identifier for the lessee
drm_mode_list_lesees
List the identifiers of the lessees for a master file
drm_mode_get_lease
List the leased objects for a master file
drm_mode_revoke_lease
Erase the set of objects managed by a lease.
This should suffice to at least create and query leases.
Changes for v2 as suggested by Daniel Vetter <[email protected]>:
* query ioctls only query the master associated with the provided file.
* 'mask_lease' value has been removed
* change ioctl has been removed.
Changes for v3 suggested in part by Dave Airlie <[email protected]>
* Add revoke ioctl.
--- drivers/gpu/drm/drm_ioctl.c | 4 + drivers/gpu/drm/drm_lease.c | 270 ++++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_lease.h | 12 ++ include/uapi/drm/drm.h | 5 + include/uapi/drm/drm_mode.h | 64 +++++++++++ 5 files changed, 355 insertions(+)
drivers/gpu/drm/drm_ioctl.c +4 -0
@@ -657,6 +657,10 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW),DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE , drm_syncobj_fd_to_handle_ioctl,DRM_UNLOCKED |DRM_RENDER_ALLOW ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_CREATE_LEASE , drm_mode_create_lease_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_LIST_LESSEES , drm_mode_list_lessees_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_GET_LEASE , drm_mode_get_lease_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), + DRM_IOCTL_DEF(DRM_IOCTL_MODE_REVOKE_LEASE, drm_mode_revoke_lease_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), };#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )
drivers/gpu/drm/drm_lease.c +270 -0
279 lines not on this page · raw message
include/drm/drm_lease.h +12 -0
@@ -33,4 +33,16 @@ uint32_t drm_lease_filter_crtcs(struct drm_file *file_priv, uint32_t crtcs);uint32_t drm_lease_filter_encoders (struct drm_file *file_priv,uint32_t encoders); +int drm_mode_create_lease_ioctl (struct drm_device *dev, +void *data,struct drm_file *file_priv); + +int drm_mode_list_lessees_ioctl (struct drm_device *dev, +void *data,struct drm_file *file_priv); + +int drm_mode_get_lease_ioctl (struct drm_device *dev, +void *data,struct drm_file *file_priv); + +int drm_mode_revoke_lease_ioctl (struct drm_device *dev, +void *data,struct drm_file *file_priv); +#endif /* _DRM_LEASE_H_ */
include/uapi/drm/drm.h +5 -0
@@ -841,6 +841,11 @@ extern "C" {#define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD DRM_IOWR(0xC1, struct drm_syncobj_handle)#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE DRM_IOWR(0xC2, struct drm_syncobj_handle) +#define DRM_IOCTL_MODE_CREATE_LEASE DRM_IOWR(0xC3, struct drm_mode_create_lease) +#define DRM_IOCTL_MODE_LIST_LESSEES DRM_IOWR(0xC4, struct drm_mode_list_lessees) +#define DRM_IOCTL_MODE_GET_LEASE DRM_IOWR(0xC5, struct drm_mode_get_lease) +#define DRM_IOCTL_MODE_REVOKE_LEASE DRM_IOWR(0xC6, struct drm_mode_revoke_lease) +/** * Device specific ioctls should only be in their respective headers * The device specific ioctl range is from 0x40 to 0x9f.
include/uapi/drm/drm_mode.h +64 -0
70 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerRe: [PATCH 6/6] drm: Add four ioctls for managing drm mode object leases [v3]
Quoted 25 lines
include/uapi/drm/drm_mode.h +25
-0+/** +* Lease mode resources, creating another drm_master. +*/ +struct drm_mode_create_lease { +/** Pointer to array of object ids (__u32) */ +__u64 object_ids; +/** Number of object ids */ +__u32 object_count; +/** flags for new FD (O_CLOEXEC, etc) */ +__u32 flags; + +/** Return: unique identifier for lessee. */ +__u32 lessee_id; +/** Return: file descriptor to new drm_master file */ +__u32 fd; +}; + +/** +* List lesses from a drm_master +*/ +struct drm_mode_list_lessees { +/** Number of lessees. +* On input, provides length of the array. +* On output, provides total number. No +* more than the input number will be written
include/uapi/drm/drm_mode.h struct drm_mode_destroy_blob { · line 769
Quoted 10 lines
include/uapi/drm/drm_mode.h +10
-0+* back, so two calls can be used to get +* the size and then the data. +*/ +__u32 count_lessees; + +/** Pointer to lessees. +* pointer to __u64 array of lessee ids +*/ +__u64 lessees_ptr; +};
I think this needs a pad ^.
Quoted 8 lines
include/uapi/drm/drm_mode.h +8
-0+ +/** +* Get leased objects +*/ +struct drm_mode_get_lease { +/** Number of leased objects. +* On input, provides length of the array. +* On output, provides total number. No
include/uapi/drm/drm_mode.h struct drm_mode_destroy_blob { · line 787
Quoted 10 lines
include/uapi/drm/drm_mode.h +10
-0+* more than the input number will be written +* back, so two calls can be used to get +* the size and then the data. +*/ +__u32 count_objects; + +/** Pointer to objects. +* pointer to __u32 array of object ids +*/ +__u64 objects_ptr;
And this.
include/uapi/drm/drm_mode.h struct drm_mode_destroy_blob { · line 796
Quoted 9 lines
include/uapi/drm/drm_mode.h +9
-0+}; + +/** +* Revoke lease +*/ +struct drm_mode_revoke_lease { +/** Unique ID of lessee +*/ +__u32 lessee_id;
And this.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 6/6] drm: Add four ioctls for managing drm mode object leases [v3]
Quoted 3 lines · Dave Airlie
I think this needs a pad ^.
And this.
Yup. Thanks!
Quoted 6 lines
include/uapi/drm/drm_mode.h struct drm_mode_destroy_blob { · line 796
Quoted 4 lines
include/uapi/drm/drm_mode.h +4
-0+struct drm_mode_revoke_lease { +/** Unique ID of lessee +*/ +__u32 lessee_id;And this.
None of the other bare 32-bit ioctl structures are padded; I think that's probably fine as they'll be 4 bytes on both 64-bit and 32-bit machines.
Signature · 1 line
-keith
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerRe: [PATCH 6/6] drm: Add four ioctls for managing drm mode object leases [v3]
In reply to Keith PackardQuoted 28 lines
--- drivers/gpu/drm/drm_ioctl.c | 4 + drivers/gpu/drm/drm_lease.c | 270 ++++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_lease.h | 12 ++ include/uapi/drm/drm.h | 5 + include/uapi/drm/drm_mode.h | 64 +++++++++++ 5 files changed, 355 insertions(+)drivers/gpu/drm/drm_ioctl.c +4
-0@@ -657,6 +657,10 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW),DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE , drm_syncobj_fd_to_handle_ioctl,DRM_UNLOCKED |DRM_RENDER_ALLOW ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_CREATE_LEASE , drm_mode_create_lease_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_LIST_LESSEES , drm_mode_list_lessees_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_GET_LEASE , drm_mode_get_lease_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), + DRM_IOCTL_DEF(DRM_IOCTL_MODE_REVOKE_LEASE, drm_mode_revoke_lease_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), };#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )drivers/gpu/drm/drm_lease.c +0
-0
drivers/gpu/drm/drm_lease.c line 26
Quoted 4 lines
drivers/gpu/drm/drm_lease.c +1
-0@@ -23,6 +23,8 @@#define drm_for_each_lessee (lessee, lessor) \ list_for_each_entry((lessee), &(lessor)->lessees, lessee_list) +static uint64_t drm_lease_idr_object;
What is this for? ^^
drivers/gpu/drm/drm_lease.c void _drm_lease_revoke(struct drm_master *top) · line 431
Quoted 1 line
drivers/gpu/drm/drm_lease.c +1
-0+ ret =idr_alloc (&leases, &drm_lease_idr_object , object_id, object_id +1 ,GFP_KERNEL );
You can just pass NULL here.
Dave.
Dave Airlie
maintainerRe: [PATCH 6/6] drm: Add four ioctls for managing drm mode object leases [v3]
Quoted 31 lines · Dave Airlie
Quoted 31 lines
--- drivers/gpu/drm/drm_ioctl.c | 4 + drivers/gpu/drm/drm_lease.c | 270 ++++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_lease.h | 12 ++ include/uapi/drm/drm.h | 5 + include/uapi/drm/drm_mode.h | 64 +++++++++++ 5 files changed, 355 insertions(+)drivers/gpu/drm/drm_ioctl.c +4
-0@@ -657,6 +657,10 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW),DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE , drm_syncobj_fd_to_handle_ioctl,DRM_UNLOCKED |DRM_RENDER_ALLOW ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_CREATE_LEASE , drm_mode_create_lease_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_LIST_LESSEES , drm_mode_list_lessees_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_GET_LEASE , drm_mode_get_lease_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), + DRM_IOCTL_DEF(DRM_IOCTL_MODE_REVOKE_LEASE, drm_mode_revoke_lease_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), };#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )drivers/gpu/drm/drm_lease.c +0
-0@@ -23,6 +23,8 @@#define drm_for_each_lessee (lessee, lessor) \ list_for_each_entry((lessee), &(lessor)->lessees, lessee_list)
Quoted 8 lines
drivers/gpu/drm/drm_lease.c line 26
Quoted 1 line
drivers/gpu/drm/drm_lease.c +1
-0+static uint64_t drm_lease_idr_object;What is this for? ^^
drivers/gpu/drm/drm_lease.c void _drm_lease_revoke(struct drm_master *top) · line 431
Quoted 1 line
drivers/gpu/drm/drm_lease.c +1
-0+ ret =idr_alloc (&leases, &drm_lease_idr_object , object_id, object_id +1 ,GFP_KERNEL );You can just pass NULL here.
Just read the comment, this smells a bit of black magic, I'll spend some time staring at it :-)
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerRe: [PATCH 6/6] drm: Add four ioctls for managing drm mode object leases [v3]
Quoted 36 lines · Dave Airlie
Quoted 35 lines · Dave Airlie
Quoted 28 lines
--- drivers/gpu/drm/drm_ioctl.c | 4 + drivers/gpu/drm/drm_lease.c | 270 ++++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_lease.h | 12 ++ include/uapi/drm/drm.h | 5 + include/uapi/drm/drm_mode.h | 64 +++++++++++ 5 files changed, 355 insertions(+)drivers/gpu/drm/drm_ioctl.c +4
-0@@ -657,6 +657,10 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW),DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE , drm_syncobj_fd_to_handle_ioctl,DRM_UNLOCKED |DRM_RENDER_ALLOW ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_CREATE_LEASE , drm_mode_create_lease_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_LIST_LESSEES , drm_mode_list_lessees_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_GET_LEASE , drm_mode_get_lease_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), + DRM_IOCTL_DEF(DRM_IOCTL_MODE_REVOKE_LEASE, drm_mode_revoke_lease_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), };#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )drivers/gpu/drm/drm_lease.c +0
-0drivers/gpu/drm/drm_lease.c line 26
Quoted 4 lines
drivers/gpu/drm/drm_lease.c +1
-0@@ -23,6 +23,8 @@#define drm_for_each_lessee (lessee, lessor) \ list_for_each_entry((lessee), &(lessor)->lessees, lessee_list) +static uint64_t drm_lease_idr_object;What is this for? ^^
Quoted 7 lines
Quoted 4 lines
drivers/gpu/drm/drm_lease.c void _drm_lease_revoke(struct drm_master *top) · line 431
Quoted 1 line
drivers/gpu/drm/drm_lease.c +1
-0+ ret =idr_alloc (&leases, &drm_lease_idr_object , object_id, object_id +1 ,GFP_KERNEL );You can just pass NULL here.
Just read the comment, this smells a bit of black magic, I'll spend some time staring at it :-)
I think a comment in here is definitely warranted with what you expect from the idr interface here.
You seem to be storing the object ids in it from the user, and failing if you get a duplicate, then later dequeuing the idr.
I'm not sure this an intended use of idr :-), my brain is saying a bitmap would work just as well, or even why we want/need deduplication here. If userspace does something stupid does it matter?
Because otherwise you could just memdup_user the array of ids, and pass that in without the idr stuff.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 6/6] drm: Add four ioctls for managing drm mode object leases [v3]
Quoted 2 lines · Dave Airlie
I think a comment in here is definitely warranted with what you expect from the idr interface here.
I've added a longer comment where this value is used; I tried replacing the IDR with a sorted array and the result wasn't any easier to use or understand. I'm pretty sure it would be more efficient, but as leases contain only a few objects in the cases we're considering, it's hard to get worked up about performance when the code is larger and mostly not any easier to understand. Feel free to take a look at that:
git://people.freedesktop.org/~keithp/linux drm-lease-array
Quoted 2 lines
Because otherwise you could just
memdup_userthe array of ids, and pass that in without the idr stuff.
Yeah, that part was more efficient. The rest of the places using this data were longer. I guess I could bail on sorting the array, but I fear someone would come up with a place needing a huge lease list, and then we'd find performance issues.
Thanks for your review; I've sent out a new series and pushed it to my repo in the drm-lease-v4 branch
Signature · 1 line
-keith
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel