Atomic modesetting v2
Subsystems (3)
cover Atomic modesetting v2
Second version of the atomic mode setting work. Still very much work in progress.
I decided that I can't afford to fight the drm_crtc_helper architecture due to the sheer amount of driver code depending on it. So I changed the code to do things in way that more closely matches drm_crtc_helper.
Next I'll be moving the buffer pinning to happen before any hw state is clobbered. This will avoid having to do actual rollbacks when pinning fails. And a similar treatment needs to be done to the PLL calculations (those should be done before buffer pinning).
I didn't re-post all the i915 specific bits I have in my tree since those didn't really change. I pushed the whole work to the drm_atomic_2 branch at https://gitorious.org/vsyrjala/linux.
RFC PATCH 1/10 drm: Export drm_property_create_blob() and drm_property_destroy_blob()
From: Ville Syrjälä <[email protected]>
--- drivers/gpu/drm/drm_crtc.c | 8 +++++--- include/drm/drm_crtc.h | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_crtc.c +5 -3
@@ -3044,8 +3044,8 @@ done:return ret; } -static struct drm_property_blob *drm_property_create_blob (struct drm_device *dev,int length, -void *data) +struct drm_property_blob *drm_property_create_blob (struct drm_device *dev,int length, +void *data) {struct drm_property_blob *blob;int ret;
@@ -3070,14 +3070,16 @@ static struct drm_property_blob *drm_property_create_blob(struct drm_device *devlist_add_tail (&blob->head, &dev->mode_config.property_blob_list);return blob; } +EXPORT_SYMBOL (drm_property_create_blob); -static void drm_property_destroy_blob (struct drm_device *dev, +void drm_property_destroy_blob (struct drm_device *dev,struct drm_property_blob *blob) {drm_mode_object_put (dev, &blob->base);list_del (&blob->head);kfree (blob); } +EXPORT_SYMBOL (drm_property_destroy_blob);int drm_mode_getblob_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv)
include/drm/drm_crtc.h +4 -0
@@ -952,6 +952,10 @@ struct drm_property *drm_property_create_range(struct drm_device *dev, int flagsconst char *name, uint64_t min, uint64_t max);extern void drm_property_destroy (struct drm_device *dev,struct drm_property *property); +extern struct drm_property_blob *drm_property_create_blob (struct drm_device *dev, +int length,void *data); +extern void drm_property_destroy_blob (struct drm_device *dev, +struct drm_property_blob *blob);extern int drm_property_add_enum (struct drm_property *property,int index,uint64_t value,const char *name);extern int drm_mode_create_dvi_i_properties (struct drm_device *dev);
Signature · 6 lines
1.7.3.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC PATCH 2/10 drm: Allow signed values for range properties
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Treat a range property as signed when the unsigned minimum value is larger than the unsigned maximum value.
--- drivers/gpu/drm/drm_crtc.c | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_crtc.c +14 -3
@@ -3143,14 +3143,25 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector, }EXPORT_SYMBOL (drm_mode_connector_update_edid_property); -static bool drm_property_change_is_valid (struct drm_property *property, +static bool range_property_is_signed (const struct drm_property *property) +{ +return property->values[0 ] > property->values[1 ]; +} + +static bool drm_property_change_is_valid (const struct drm_property *property,uint64_t value) {if (property->flags &DRM_MODE_PROP_IMMUTABLE )return false;if (property->flags &DRM_MODE_PROP_RANGE ) { -if (value < property->values[0 ] || value > property->values[1 ]) -return false; +if (range_property_is_signed (property)) { +if ((int64_t )value < (int64_t )property->values[0 ] || + (int64_t )value > (int64_t )property->values[1 ]) +return false; + }else { +if (value < property->values[0 ] || value > property->values[1 ]) +return false; + }return true; }else if (property->flags &DRM_MODE_PROP_BITMASK ) {int i;
Signature · 6 lines
1.7.3.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC PATCH 3/10 drm: Allow drm_mode_object_find() to look up an object of any type
In reply to [email protected]From: Ville Syrjälä <[email protected]>
To avoid having to pass object types from userspace for atomic mode setting ioctl, allow drm_mode_object_find() to look up an object of any type. This will only work as long as the all object types share the ID space.
--- drivers/gpu/drm/drm_crtc.c | 3 ++- include/drm/drm_crtc.h | 1 + 2 files changed, 3 insertions(+), 1 deletions(-)
drivers/gpu/drm/drm_crtc.c +2 -1
@@ -268,7 +268,8 @@ struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,mutex_lock (&dev->mode_config.idr_mutex); obj =idr_find (&dev->mode_config.crtc_idr, id); -if (!obj || (obj->type != type) || (obj->id != id)) +if (!obj || (type !=DRM_MODE_OBJECT_ANY && obj->type != type) || + (obj->id != id)) obj =NULL ;mutex_unlock (&dev->mode_config.idr_mutex);
include/drm/drm_crtc.h +1 -0
@@ -47,6 +47,7 @@ struct drm_object_properties;#define DRM_MODE_OBJECT_FB 0xfbfbfbfb#define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb#define DRM_MODE_OBJECT_PLANE 0xeeeeeeee +#define DRM_MODE_OBJECT_ANY 0struct drm_mode_object {uint32_t id;
Signature · 6 lines
1.7.3.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC PATCH 4/10 drm: Export drm_encoder_crtc_ok
In reply to [email protected]From: Ville Syrjälä <[email protected]>
--- drivers/gpu/drm/drm_crtc_helper.c | 5 +++-- include/drm/drm_crtc_helper.h | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_crtc_helper.c +3 -2
@@ -279,8 +279,8 @@ EXPORT_SYMBOL(drm_helper_disable_unused_functions);* * Return false if @encoder can't be driven by @crtc, true otherwise. */ -static bool drm_encoder_crtc_ok (struct drm_encoder *encoder, -struct drm_crtc *crtc) +bool drm_encoder_crtc_ok (struct drm_encoder *encoder, +struct drm_crtc *crtc) {struct drm_device *dev;struct drm_crtc *tmp;
@@ -300,6 +300,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,return true;return false; } +EXPORT_SYMBOL (drm_encoder_crtc_ok);/* * Check the CRTC we're going to map each output to vs. its current
include/drm/drm_crtc_helper.h +3 -0
@@ -166,4 +166,7 @@ extern void drm_helper_hpd_irq_event(struct drm_device *dev);extern void drm_kms_helper_poll_disable (struct drm_device *dev);extern void drm_kms_helper_poll_enable (struct drm_device *dev); +extern bool drm_encoder_crtc_ok (struct drm_encoder *encoder, +struct drm_crtc *crtc); +#endif
Signature · 6 lines
1.7.3.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC PATCH 5/10 drm: Export drm_crtc_prepare_encoders()
In reply to [email protected]From: Ville Syrjälä <[email protected]>
--- drivers/gpu/drm/drm_crtc_helper.c | 3 ++- include/drm/drm_crtc_helper.h | 1 + 2 files changed, 3 insertions(+), 1 deletions(-)
drivers/gpu/drm/drm_crtc_helper.c +2 -1
@@ -307,7 +307,7 @@ EXPORT_SYMBOL(drm_encoder_crtc_ok);* CRTC. If they don't match, we have to disable the output and the CRTC * since the driver will have to re-route things. */ -static void +void drm_crtc_prepare_encoders (struct drm_device *dev) {struct drm_encoder_helper_funcs *encoder_funcs;
@@ -324,6 +324,7 @@ drm_crtc_prepare_encoders(struct drm_device *dev)drm_encoder_disable (encoder); } } +EXPORT_SYMBOL (drm_crtc_prepare_encoders);/** * drm_crtc_set_mode - set a mode
include/drm/drm_crtc_helper.h +1 -0
@@ -168,5 +168,6 @@ extern void drm_kms_helper_poll_enable(struct drm_device *dev);extern bool drm_encoder_crtc_ok (struct drm_encoder *encoder,struct drm_crtc *crtc); +extern void drm_crtc_prepare_encoders (struct drm_device *dev);#endif
Signature · 6 lines
1.7.3.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC PATCH 6/10 drm: Refactor object property check code
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Refactor the code to check whether an object has a specific property to a new function.
--- drivers/gpu/drm/drm_crtc.c | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_crtc.c +14 -6
@@ -3301,6 +3301,19 @@ out:return ret; } +static bool object_has_prop (const struct drm_mode_object *obj,u32 prop_id) +{ +int i; + +if (!obj->properties) +return false; + +for (i =0 ; i < obj->properties->count; i++) +if (obj->properties->ids[i] == prop_id) +return true; +return false; +} +int drm_mode_obj_set_property_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv) {
@@ -3309,7 +3322,6 @@ int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,struct drm_mode_object *prop_obj;struct drm_property *property;int ret = -EINVAL ; -int i;if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ;
@@ -3322,11 +3334,7 @@ int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,if (!arg_obj->properties) goto out; -for (i =0 ; i < arg_obj->properties->count; i++) -if (arg_obj->properties->ids[i] == arg->prop_id) -break ; - -if (i == arg_obj->properties->count) +if (!object_has_prop (arg_obj, arg->prop_id)) goto out; prop_obj = drm_mode_object_find(dev, arg->prop_id,
Signature · 6 lines
1.7.3.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC PATCH 7/10 drm: Add MODE_IDS property to connectors
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Add a new blob property MODE_IDS to connectors. This property contains a list a mode object IDs attached to the connector (either probed modes, or user attached modes).
--- drivers/gpu/drm/drm_crtc.c | 77 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_crtc_helper.c | 1 + include/drm/drm_crtc.h | 2 + 3 files changed, 80 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_crtc.c +77 -0
@@ -508,6 +508,9 @@ int drm_connector_init(struct drm_device *dev,drm_connector_attach_property (connector, dev->mode_config.dpms_property,0 ); +drm_connector_attach_property (connector, + dev->mode_config.mode_ids_property,0 ); + out:mutex_unlock (&dev->mode_config.mutex);
@@ -713,6 +716,7 @@ static int drm_mode_create_standard_connector_properties(struct drm_device *dev) {struct drm_property *edid;struct drm_property *dpms; +struct drm_property *mode_ids;/* * Standard properties (apply to all connectors)
@@ -727,6 +731,11 @@ static int drm_mode_create_standard_connector_properties(struct drm_device *dev) ARRAY_SIZE(drm_dpms_enum_list)); dev->mode_config.dpms_property = dpms; + mode_ids =drm_property_create (dev,DRM_MODE_PROP_BLOB | +DRM_MODE_PROP_IMMUTABLE , +"MODE_IDS" ,0 ); + dev->mode_config.mode_ids_property = mode_ids; +return 0 ; }
@@ -2648,6 +2657,10 @@ int drm_mode_attachmode_ioctl(struct drm_device *dev, }drm_mode_attachmode (dev, connector, mode); + + ret =drm_mode_connector_update_mode_ids_property (connector); +if (ret) +drm_mode_remove (connector, mode); out:mutex_unlock (&dev->mode_config.mutex);return ret;
@@ -3144,6 +3157,70 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector, }EXPORT_SYMBOL (drm_mode_connector_update_edid_property); +int drm_mode_connector_update_mode_ids_property (struct drm_connector *connector) +{ +struct drm_device *dev = connector->dev; +struct drm_property_blob *blob =NULL ; +struct drm_property_blob *old_blob =NULL ; +struct drm_display_mode *mode; +uint64_t value; +int i =0 ; +int ret; + + ret =drm_connector_property_get_value (connector, + dev->mode_config.mode_ids_property, + &value); +if (ret) +return ret; + +if (value) { +struct drm_mode_object *obj =drm_mode_object_find (dev, value,DRM_MODE_OBJECT_BLOB ); +if (!obj) +return -ENOENT ; + + old_blob =obj_to_blob (obj); + } + +list_for_each_entry (mode, &connector->modes, head) + i++; +list_for_each_entry (mode, &connector->user_modes, head) + i++; + +if (i) { +uint32_t *mode_ids =kcalloc (i,sizeof mode_ids[0 ],GFP_KERNEL ); +if (!mode_ids) +return -ENOMEM ; + + i =0 ; +list_for_each_entry (mode, &connector->modes, head) + mode_ids[i++] = mode->base.id; +list_for_each_entry (mode, &connector->user_modes, head) + mode_ids[i++] = mode->base.id; + + blob =drm_property_create_blob (dev, i *sizeof mode_ids[0 ], mode_ids); + +kfree (mode_ids); + +if (!blob) +return -ENOMEM ; + } + + ret =drm_connector_property_set_value (connector, + dev->mode_config.mode_ids_property, + blob ? blob->base.id :0 ); +if (ret) { +if (blob) +drm_property_destroy_blob (dev, blob); +return ret; + } + +if (old_blob) +drm_property_destroy_blob (dev, old_blob); + +return ret; +} +EXPORT_SYMBOL (drm_mode_connector_update_mode_ids_property); +static bool range_property_is_signed (const struct drm_property *property) {return property->values[0 ] > property->values[1 ];
drivers/gpu/drm/drm_crtc_helper.c +1 -0
@@ -131,6 +131,7 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector, goto prune;drm_mode_connector_list_update (connector); +drm_mode_connector_update_mode_ids_property (connector);if (maxX && maxY) drm_mode_validate_size(dev, &connector->modes, maxX,
include/drm/drm_crtc.h +2 -0
@@ -790,6 +790,7 @@ struct drm_mode_config {struct list_head property_blob_list;struct drm_property *edid_property;struct drm_property *dpms_property; +struct drm_property *mode_ids_property;/* DVI-I properties */ struct drm_property *dvi_i_subconnector_property;
@@ -910,6 +911,7 @@ extern void drm_mode_set_crtcinfo(struct drm_display_mode *p,extern void drm_mode_connector_list_update (struct drm_connector *connector);extern int drm_mode_connector_update_edid_property (struct drm_connector *connector,struct edid *edid); +extern int drm_mode_connector_update_mode_ids_property (struct drm_connector *connector);extern int drm_connector_property_set_value (struct drm_connector *connector,struct drm_property *property,uint64_t value);
Signature · 6 lines
1.7.3.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC PATCH 8/10 WIP: drm: Atomic modeset ioctl
In reply to [email protected]From: Ville Syrjälä <[email protected]>
First draft.
The ioctl simply takes a list of object IDs and property IDs and their values. For setting values to blob properties, the property value indicates the length of the data, and the actual data is passed via another blob pointer.
Detailed error reporting is missing, as is completion event support.
--- drivers/gpu/drm/drm_crtc.c | 133 ++++++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_drv.c | 1 + include/drm/drm.h | 1 + include/drm/drmP.h | 2 + include/drm/drm_crtc.h | 12 ++++ include/drm/drm_mode.h | 14 +++++ 6 files changed, 163 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_crtc.c +133 -0
@@ -4201,3 +4201,136 @@ int drm_calc_vscale(struct drm_region *src, struct drm_region *dst,return vscale; }EXPORT_SYMBOL (drm_calc_vscale); + +int drm_mode_atomic_ioctl (struct drm_device *dev, +void *data,struct drm_file *file_priv) +{ +struct drm_mode_atomic *arg = data; +uint32_t __user *objs_ptr = (uint32_t __user *)(unsigned long )(arg->objs_ptr); +uint32_t __user *count_props_ptr = (uint32_t __user *)(unsigned long )(arg->count_props_ptr); +uint32_t __user *props_ptr = (uint32_t __user *)(unsigned long )(arg->props_ptr); +uint64_t __user *prop_values_ptr = (uint64_t __user *)(unsigned long )(arg->prop_values_ptr); +uint64_t __user *blob_values_ptr = (uint64_t __user *)(unsigned long )(arg->blob_values_ptr); +unsigned int copied_objs =0 ; +unsigned int copied_props =0 ; +unsigned int copied_blobs =0 ; +void *state; +int ret =0 ; +unsigned int i, j; + +if (!dev->driver->atomic_funcs || + !dev->driver->atomic_funcs->begin || + !dev->driver->atomic_funcs->set || + !dev->driver->atomic_funcs->check || + !dev->driver->atomic_funcs->commit || + !dev->driver->atomic_funcs->end) +return -ENOSYS ; + +if (arg->flags & ~DRM_ATOMIC_TEST_ONLY ) +return -EINVAL ; + +mutex_lock (&dev->mode_config.mutex); + + state = dev->driver->atomic_funcs->begin (dev, arg->flags); +if (IS_ERR (state)) { + ret =PTR_ERR (state); + goto unlock; + } + +for (i =0 ; i < arg->count_objs; i++) { +uint32_t obj_id, count_props; +struct drm_mode_object *obj; + +if (get_user (obj_id, objs_ptr + copied_objs)) { + ret = -EFAULT ; + goto out; + } + + obj =drm_mode_object_find (dev, obj_id,DRM_MODE_OBJECT_ANY ); +if (!obj || !obj->properties) { + ret = -ENOENT ; + goto out; + } + +if (get_user (count_props, count_props_ptr + copied_objs)) { + ret = -EFAULT ; + goto out; + } + + copied_objs++; + +for (j =0 ; j < count_props; j++) { +uint32_t prop_id; +uint64_t prop_value; +struct drm_mode_object *prop_obj; +struct drm_property *prop; +void *blob_data =NULL ; + +if (get_user (prop_id, props_ptr + copied_props)) { + ret = -EFAULT ; + goto out; + } + +if (!object_has_prop (obj, prop_id)) { + ret = -EINVAL ; + goto out; + } + + prop_obj =drm_mode_object_find (dev, prop_id,DRM_MODE_OBJECT_PROPERTY ); +if (!prop_obj) { + ret = -ENOENT ; + goto out; + } + prop =obj_to_property (prop_obj); + +if (get_user (prop_value, prop_values_ptr + copied_props)) { + ret = -EFAULT ; + goto out; + } + +if (!drm_property_change_is_valid (prop, prop_value)) { + ret = -EINVAL ; + goto out; + } + +if (prop->flags &DRM_MODE_PROP_BLOB && prop_value) { + blob_data =kmalloc (prop_value,GFP_KERNEL ); +if (!blob_data) { + ret = -ENOMEM ; + goto out; + } + +if (copy_from_user (blob_data, blob_values_ptr + copied_blobs, prop_value)) { +kfree (blob_data); + ret = -EFAULT ; + goto out; + } + + copied_blobs++; + } + +/* The driver will be in charge of blob_data from now on. */ + ret = dev->driver->atomic_funcs->set (dev, state, obj, prop, prop_value, blob_data); +if (ret) + goto out; + + copied_props++; + } + } + + ret = dev->driver->atomic_funcs->check (dev, state); +if (ret) + goto out; + +if (arg->flags &DRM_ATOMIC_TEST_ONLY ) + goto out; + + ret = dev->driver->atomic_funcs->commit (dev, state); + + out: + dev->driver->atomic_funcs->end (dev, state); + unlock: +mutex_unlock (&dev->mode_config.mutex); + +return ret; +}
drivers/gpu/drm/drm_drv.c +1 -0
@@ -166,6 +166,7 @@ static struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_MODE_DESTROY_DUMB , drm_mode_destroy_dumb_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_OBJ_GETPROPERTIES , drm_mode_obj_get_properties_ioctl,DRM_MASTER |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_ATOMIC, drm_mode_atomic_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), };#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )
include/drm/drm.h +1 -0
@@ -732,6 +732,7 @@ struct drm_prime_handle {#define DRM_IOCTL_MODE_ADDFB2 DRM_IOWR(0xB8, struct drm_mode_fb_cmd2)#define DRM_IOCTL_MODE_OBJ_GETPROPERTIES DRM_IOWR(0xB9, struct drm_mode_obj_get_properties)#define DRM_IOCTL_MODE_OBJ_SETPROPERTY DRM_IOWR(0xBA, struct drm_mode_obj_set_property) +#define DRM_IOCTL_MODE_ATOMIC DRM_IOWR(0xBB, struct drm_mode_atomic)/** * Device specific ioctls should only be in their respective headers
include/drm/drmP.h +2 -0
@@ -964,6 +964,8 @@ struct drm_driver {/* List of devices hanging off this driver */ struct list_head device_list; + +const struct drm_atomic_funcs *atomic_funcs; };#define DRM_MINOR_UNASSIGNED 0
include/drm/drm_crtc.h +12 -0
@@ -1065,6 +1065,8 @@ extern int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);extern int drm_mode_obj_set_property_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv); +extern int drm_mode_atomic_ioctl (struct drm_device *dev, +void *data,struct drm_file *file_priv);extern void drm_fb_get_bpp_depth (uint32_t format,unsigned int *depth,int *bpp);
@@ -1101,4 +1103,14 @@ extern int drm_calc_hscale(struct drm_region *src, struct drm_region *dst,extern int drm_calc_vscale (struct drm_region *src,struct drm_region *dst,int min_vscale,int max_vscale); +struct drm_atomic_funcs { +void *(*begin)(struct drm_device *dev,uint32_t flags); +int (*set)(struct drm_device *dev,void *state, +struct drm_mode_object *obj,struct drm_property *prop, +uint64_t value,void *blob_data); +int (*check)(struct drm_device *dev,void *state); +int (*commit)(struct drm_device *dev,void *state); +void (*end)(struct drm_device *dev,void *state); +}; +#endif /* __DRM_CRTC_H__ */
include/drm/drm_mode.h +14 -0
@@ -459,4 +459,18 @@ struct drm_mode_destroy_dumb { uint32_t handle; }; + +#define DRM_ATOMIC_TEST_ONLY (1<<0) + +/* FIXME come up with some sane error reporting mechanism? */ +struct drm_mode_atomic { +__u32 flags; +__u32 count_objs; +__u64 objs_ptr; +__u64 count_props_ptr; +__u64 props_ptr; +__u64 prop_values_ptr; +__u64 blob_values_ptr; +}; +#endif
Signature · 6 lines
1.7.3.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 08/10] WIP: drm: Atomic modeset ioctl
Quoted 10 lines · On Wed, Jun 27, 2012 at 5:24 AM, <[email protected]> wrote:
From: Ville Syrjälä <[email protected]>
First draft.
The ioctl simply takes a list of object IDs and property IDs and their values. For setting values to blob properties, the property value indicates the length of the data, and the actual data is passed via another blob pointer.
Detailed error reporting is missing, as is completion event support.
Hmm, I'm thinking we may need to define a bit in the way of semantics.. ie. I think we really do want things like enabling/disabling a plane to be asynchronous (after doing a DRM_ATOMIC_TEST_ONLY call), otherwise performance will suck when switching a window surface to/from a plane. But maybe we should define that another DRM_IOCTL_MODE_ATOMIC cannot come until after some sort of event back to userspace?
Quoted 156 lines
Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_crtc.c | 133 ++++++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_drv.c | 1 + include/drm/drm.h | 1 + include/drm/drmP.h | 2 + include/drm/drm_crtc.h | 12 ++++ include/drm/drm_mode.h | 14 +++++ 6 files changed, 163 insertions(+), 0 deletions(-)drivers/gpu/drm/drm_crtc.c +133
-0@@ -4201,3 +4201,136 @@ int drm_calc_vscale(struct drm_region *src, struct drm_region *dst,return vscale; }EXPORT_SYMBOL (drm_calc_vscale); + +int drm_mode_atomic_ioctl (struct drm_device *dev, +void *data,struct drm_file *file_priv) +{ +struct drm_mode_atomic *arg = data; +uint32_t __user *objs_ptr = (uint32_t __user *)(unsigned long )(arg->objs_ptr); +uint32_t __user *count_props_ptr = (uint32_t __user *)(unsigned long )(arg->count_props_ptr); +uint32_t __user *props_ptr = (uint32_t __user *)(unsigned long )(arg->props_ptr); +uint64_t __user *prop_values_ptr = (uint64_t __user *)(unsigned long )(arg->prop_values_ptr); +uint64_t __user *blob_values_ptr = (uint64_t __user *)(unsigned long )(arg->blob_values_ptr); +unsigned int copied_objs =0 ; +unsigned int copied_props =0 ; +unsigned int copied_blobs =0 ; +void *state; +int ret =0 ; +unsigned int i, j; + +if (!dev->driver->atomic_funcs || + !dev->driver->atomic_funcs->begin || + !dev->driver->atomic_funcs->set || + !dev->driver->atomic_funcs->check || + !dev->driver->atomic_funcs->commit || + !dev->driver->atomic_funcs->end) +return -ENOSYS ; + +if (arg->flags & ~DRM_ATOMIC_TEST_ONLY ) +return -EINVAL ; + +mutex_lock (&dev->mode_config.mutex); + + state = dev->driver->atomic_funcs->begin (dev, arg->flags); +if (IS_ERR (state)) { + ret =PTR_ERR (state); + goto unlock; + } + +for (i =0 ; i < arg->count_objs; i++) { +uint32_t obj_id, count_props; +struct drm_mode_object *obj; + +if (get_user (obj_id, objs_ptr + copied_objs)) { + ret = -EFAULT ; + goto out; + } + + obj =drm_mode_object_find (dev, obj_id,DRM_MODE_OBJECT_ANY ); +if (!obj || !obj->properties) { + ret = -ENOENT ; + goto out; + } + +if (get_user (count_props, count_props_ptr + copied_objs)) { + ret = -EFAULT ; + goto out; + } + + copied_objs++; + +for (j =0 ; j < count_props; j++) { +uint32_t prop_id; +uint64_t prop_value; +struct drm_mode_object *prop_obj; +struct drm_property *prop; +void *blob_data =NULL ; + +if (get_user (prop_id, props_ptr + copied_props)) { + ret = -EFAULT ; + goto out; + } + +if (!object_has_prop (obj, prop_id)) { + ret = -EINVAL ; + goto out; + } + + prop_obj =drm_mode_object_find (dev, prop_id,DRM_MODE_OBJECT_PROPERTY ); +if (!prop_obj) { + ret = -ENOENT ; + goto out; + } + prop =obj_to_property (prop_obj); + +if (get_user (prop_value, prop_values_ptr + copied_props)) { + ret = -EFAULT ; + goto out; + } + +if (!drm_property_change_is_valid (prop, prop_value)) { + ret = -EINVAL ; + goto out; + } + +if (prop->flags &DRM_MODE_PROP_BLOB && prop_value) { + blob_data =kmalloc (prop_value,GFP_KERNEL ); +if (!blob_data) { + ret = -ENOMEM ; + goto out; + } + +if (copy_from_user (blob_data, blob_values_ptr + copied_blobs, prop_value)) { +kfree (blob_data); + ret = -EFAULT ; + goto out; + } + + copied_blobs++; + } + +/* The driver will be in charge of blob_data from now on. */ + ret = dev->driver->atomic_funcs->set (dev, state, obj, prop, prop_value, blob_data); +if (ret) + goto out; + + copied_props++; + } + } + + ret = dev->driver->atomic_funcs->check (dev, state); +if (ret) + goto out; + +if (arg->flags &DRM_ATOMIC_TEST_ONLY ) + goto out; + + ret = dev->driver->atomic_funcs->commit (dev, state); + + out: + dev->driver->atomic_funcs->end (dev, state); + unlock: +mutex_unlock (&dev->mode_config.mutex); + +return ret; +}drivers/gpu/drm/drm_drv.c +0
-0
drivers/gpu/drm/drm_drv.c static struct drm_ioctl_desc drm_ioctls[] = { · line 169
Quoted 4 lines
drivers/gpu/drm/drm_drv.c +1
-0@@ -166,6 +166,7 @@ static struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_MODE_DESTROY_DUMB , drm_mode_destroy_dumb_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_OBJ_GETPROPERTIES , drm_mode_obj_get_properties_ioctl,DRM_MASTER |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_ATOMIC, drm_mode_atomic_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
DRM_IOCTL_MODE_ATOMIC_SET? DRM_IOCTL_MODE_SET_ATOMIC? Seems like there should somehow be a "SET" in the name..
BR,
-R
Quoted 86 lines
drivers/gpu/drm/drm_drv.c +0
-0};#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )include/drm/drm.h +1
-0@@ -732,6 +732,7 @@ struct drm_prime_handle {#define DRM_IOCTL_MODE_ADDFB2 DRM_IOWR(0xB8, struct drm_mode_fb_cmd2)#define DRM_IOCTL_MODE_OBJ_GETPROPERTIES DRM_IOWR(0xB9, struct drm_mode_obj_get_properties)#define DRM_IOCTL_MODE_OBJ_SETPROPERTY DRM_IOWR(0xBA, struct drm_mode_obj_set_property) +#define DRM_IOCTL_MODE_ATOMIC DRM_IOWR(0xBB, struct drm_mode_atomic)/** * Device specific ioctls should only be in their respective headers include/drm/drmP.h +2
-0@@ -964,6 +964,8 @@ struct drm_driver {/* List of devices hanging off this driver */ struct list_head device_list; + +const struct drm_atomic_funcs *atomic_funcs; };#define DRM_MINOR_UNASSIGNED 0include/drm/drm_crtc.h +12
-0@@ -1065,6 +1065,8 @@ extern int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);extern int drm_mode_obj_set_property_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv); +extern int drm_mode_atomic_ioctl (struct drm_device *dev, +void *data,struct drm_file *file_priv);extern void drm_fb_get_bpp_depth (uint32_t format,unsigned int *depth,int *bpp);@@ -1101,4 +1103,14 @@ extern int drm_calc_hscale(struct drm_region *src, struct drm_region *dst,extern int drm_calc_vscale (struct drm_region *src,struct drm_region *dst,int min_vscale,int max_vscale); +struct drm_atomic_funcs { +void *(*begin)(struct drm_device *dev,uint32_t flags); +int (*set)(struct drm_device *dev,void *state, +struct drm_mode_object *obj,struct drm_property *prop, +uint64_t value,void *blob_data); +int (*check)(struct drm_device *dev,void *state); +int (*commit)(struct drm_device *dev,void *state); +void (*end)(struct drm_device *dev,void *state); +}; +#endif /* __DRM_CRTC_H__ */ include/drm/drm_mode.h +14
-1@@ -459,4 +459,18 @@ struct drm_mode_destroy_dumb { uint32_t handle; }; + +#define DRM_ATOMIC_TEST_ONLY (1<<0) + +/* FIXME come up with some sane error reporting mechanism? */ +struct drm_mode_atomic { +__u32 flags; +__u32 count_objs; +__u64 objs_ptr; +__u64 count_props_ptr; +__u64 props_ptr; +__u64 prop_values_ptr; +__u64 blob_values_ptr; +}; +#endif --1.7.3.4
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 08/10] WIP: drm: Atomic modeset ioctl
Quoted 12 lines · Rob Clark
Quoted 10 lines · On Wed, Jun 27, 2012 at 5:24 AM, <[email protected]> wrote:
From: Ville Syrjälä <[email protected]>
First draft.
The ioctl simply takes a list of object IDs and property IDs and their values. For setting values to blob properties, the property value indicates the length of the data, and the actual data is passed via another blob pointer.
Detailed error reporting is missing, as is completion event support.
Quoted 7 lines
Hmm, I'm thinking we may need to define a bit in the way of semantics.. ie. I think we really do want things like enabling/disabling a plane to be asynchronous (after doing a
DRM_ATOMIC_TEST_ONLYcall), otherwise performance will suck when switching a window surface to/from a plane. But maybe we should define that anotherDRM_IOCTL_MODE_ATOMICcannot come until after some sort of event back to userspace?
I've discussed things with Kristian Høgsberg (and also Jesse now that he's back from sabbatical) a lot and we've concluded on one big thing:
We should separate the issue of modeset on mutliple crtcs (usually called atomic modeset on irc) from a (usually called nuclear) pageflip on a single crtc that exchanges a bunch of things (framebufferrs, plane parameters, other properties, cursor position, ...).
The reason is that these things solve in large parts separate problems:
- atomic modeset is first and foremost a solution to exposing constraints on global configurations due to shared resources like plls, link lanes (e.g. on many intel chipset if you enable multiple outputs you can use the full bw of the single output config) and similar things. The solution is to tell the kernel the entire config and let the kernel decide how to best make it possible with the hw it has (maybe even re-assigning crtcs internally to give the display pipe with the most bandwidth to the crtc with the highest dotclock*bpp requirement). To be able to expose all this to userspace Jesse proposed a test_flag to check configurations without actually changing anything in the hw state. This way a modeset GUI could grey out everything that won't work (since describing the actual hw constraints is too complex, and users don't really care anyway in most cases why something doesn't work).
- a modeset also usually can take a few vblanks, since establishing new clocks and locking them in the various stages of the pipeline can take a while. And since modeset configuration happens seldomly, we imo can simply specify that a modeset always happens synchronously.
- Pageflip on the _must_ happen on a precise vblank, and be fully asynchronous, always. Furthermore we want a timestamp to know when the pageflip actually happened. Again, due to funny hw constraints we might need a test_flag so that a compositor can figure out whether it can use a plane for a given surface. Compared to the atomic modeset test-flag we have a few complications:
- We don't want to walk the plane configuration space in the test mode for every frame. Hence the compositor will just try the current configuration (maybe with some surfaces moved around and a few properties changed). If a given plane config doesn't work out, the compositor could just fall back to gpu rendering and try to come up with a new optimal configuration for the next frame.
- There's the issue that some changes require more than one vblank to take effect due to some prep work (e.g. switching a plane to a different crtc). My idea here is that the kernel could return a special "transient -EINVAL" for this case indicating to the compositor that it can't do this configuration for the next vblank, but it has set up things so that eventually (in a few vblanks) the sprite will be available on that crtc. The userspace compositor should then just keep on retrying for each frame with this configuration (until it either works or the kernel returns a "definit -EINVAL" indicating that something changed and it can't do this configuration). That way we should be able to support any steady-state plane/fb/cursor/whatever configuration that the hw can, without forcing the compositor to miss a frame. Obviously, these prepare steps _must_ _not_ result in a rouge plane eventually appearing ;-)
- Also a rather practical one: The lack of nuclear pageflip is the reason that Wayland/Weston can't use sprites atm (since set_plane is can be synchronous and can't be synced with a pageflip). Kristian therefore wants the atomic modeset (which I think is much more invasive) not to stall the nuclear pageflip support. And the implementation effort is imo really a big difference: For i915.ko I expect the nuclear pageflip to mostly boil down to wiring up async plane/cursor updates through the latch register (with keeping all the other setup code around since we only allow at most one outstanding pageflip per crtc currently anyway) and wiring that up with the existing crtc pageflip handler. atomic modeset otoh requires an invasive rewrite of the driver code to properly handle these shared resources (and support the test mode). The beginning of that is happening with the modeset rework, but that's just the first step.
I.e. I'm voting to reduce the scope of this ioctl a bit in the naming of gaining simpler&clearer semantics. In any case I don't see the big&scary work in the ioctl itself, but the actual low-level hw implementation in drivers (imo the crtc helper framework is holy inadequate for this safe for the simplest of drivers) and in testing the ioctl interfaces exhaustively.
Especially the testing is very important, since the entire design hinges on the test-flag to make complex configuration constraints discoverable at run-time. I think we need a few tools that random-walk the configuration space and check whether any configuration that returns -EINVAL in the test mode actually fails (and vice-versa), maybe excluding any other failures in the real modeset like -EIO (e.g. due to some stupid dp link failing to properly lock onto the stream).
Cheers, Daniel
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mobile: +41 (0)79 365 57 48
Re: [RFC][PATCH 08/10] WIP: drm: Atomic modeset ioctl
Quoted 21 lines · Daniel Vetter
Quoted 12 lines · Rob Clark
Quoted 10 lines · On Wed, Jun 27, 2012 at 5:24 AM, <[email protected]> wrote:
From: Ville Syrjälä <[email protected]>
First draft.
The ioctl simply takes a list of object IDs and property IDs and their values. For setting values to blob properties, the property value indicates the length of the data, and the actual data is passed via another blob pointer.
Detailed error reporting is missing, as is completion event support.
Quoted 7 lines
Hmm, I'm thinking we may need to define a bit in the way of semantics.. ie. I think we really do want things like enabling/disabling a plane to be asynchronous (after doing a
DRM_ATOMIC_TEST_ONLYcall), otherwise performance will suck when switching a window surface to/from a plane. But maybe we should define that anotherDRM_IOCTL_MODE_ATOMICcannot come until after some sort of event back to userspace?
Quoted 7 lines
I've discussed things with Kristian Høgsberg (and also Jesse now that he's back from sabbatical) a lot and we've concluded on one big thing:
We should separate the issue of modeset on mutliple crtcs (usually called atomic modeset on irc) from a (usually called nuclear) pageflip on a single crtc that exchanges a bunch of things (framebufferrs, plane parameters, other properties, cursor position, ...).
yeah, nuclear-pageflip would be associated only w/ a single crtc. Actually I was kinda assuming atomic-modeset was too.. ie. moving a plane from one crtc to another would be two ioctls, one to remove it from first crtc, one to add to the other. Although maybe one big ioctl is better.
I do think there is a bit of a grey area between the two. Ie. enabling/disabling a crtc, or changing what encoder->connector it is hooked to might be taking several vblank cycles, and is a relatively infrequent operation so ok to block. Enabling/disabling a plane could be much more frequent and should not block. Returning EINVAL or EBUSY in the transient case where it isn't ready quite yet seems like a good approach.. EBUSY might be better for "it might succeed if you try again in next vblank" and EINVAL for "it won't ever work with current setup, don't bother trying again".
Infrequent, can be slow:
+ enabling/disabling a new output
Semi-frequent, should not block but -EBUSY ok:
+ enabling/disabling a plane
+ resizing a plane
More frequent, should not block, should not need extra "test" ioctl step, but should just work
+ page flip, update plane position
So for that middle group, I'm a bit fuzzy on where those operations should fit in..
Quoted 48 lines
The reason is that these things solve in large parts separate problems:
- atomic modeset is first and foremost a solution to exposing constraints on global configurations due to shared resources like plls, link lanes (e.g. on many intel chipset if you enable multiple outputs you can use the full bw of the single output config) and similar things. The solution is to tell the kernel the entire config and let the kernel decide how to best make it possible with the hw it has (maybe even re-assigning crtcs internally to give the display pipe with the most bandwidth to the crtc with the highest dotclock*bpp requirement). To be able to expose all this to userspace Jesse proposed a
test_flagto check configurations without actually changing anything in the hw state. This way a modeset GUI could grey out everything that won't work (since describing the actual hw constraints is too complex, and users don't really care anyway in most cases why something doesn't work).- a modeset also usually can take a few vblanks, since establishing new clocks and locking them in the various stages of the pipeline can take a while. And since modeset configuration happens seldomly, we imo can simply specify that a modeset always happens synchronously.
- Pageflip on the _must_ happen on a precise vblank, and be fully asynchronous, always. Furthermore we want a timestamp to know when the pageflip actually happened. Again, due to funny hw constraints we might need a
test_flagso that a compositor can figure out whether it can use a plane for a given surface. Compared to the atomic modeset test-flag we have a few complications:
- We don't want to walk the plane configuration space in the test mode for every frame. Hence the compositor will just try the current configuration (maybe with some surfaces moved around and a few properties changed). If a given plane config doesn't work out, the compositor could just fall back to gpu rendering and try to come up with a new optimal configuration for the next frame.
- There's the issue that some changes require more than one vblank to take effect due to some prep work (e.g. switching a plane to a different crtc). My idea here is that the kernel could return a special "transient-EINVAL" for this case indicating to the compositor that it can't do this configuration for the next vblank, but it has set up things so that eventually (in a few vblanks) the sprite will be available on that crtc. The userspace compositor should then just keep on retrying for each frame with this configuration (until it either works or the kernel returns a "definit-EINVAL" indicating that something changed and it can't do this configuration). That way we should be able to support any steady-state plane/fb/cursor/whatever configuration that the hw can, without forcing the compositor to miss a frame. Obviously, these prepare steps _must_ _not_ result in a rouge plane eventually appearing ;-)
Quoted 14 lines
- Also a rather practical one: The lack of nuclear pageflip is the reason that Wayland/Weston can't use sprites atm (since
set_planeis can be synchronous and can't be synced with a pageflip). Kristian therefore wants the atomic modeset (which I think is much more invasive) not to stall the nuclear pageflip support. And the implementation effort is imo really a big difference: For i915.ko I expect the nuclear pageflip to mostly boil down to wiring up async plane/cursor updates through the latch register (with keeping all the other setup code around since we only allow at most one outstanding pageflip per crtc currently anyway) and wiring that up with the existing crtc pageflip handler. atomic modeset otoh requires an invasive rewrite of the driver code to properly handle these shared resources (and support the test mode). The beginning of that is happening with the modeset rework, but that's just the first step.
Hmm, I was thinking Ville's atomic fxns would be useful, but maybe I can still bits from that and try and put nuclear-pageflip beneath atomic-modeset in the stack.
BR,
-R
Quoted 20 lines
I.e. I'm voting to reduce the scope of this ioctl a bit in the naming of gaining simpler&clearer semantics. In any case I don't see the big&scary work in the ioctl itself, but the actual low-level hw implementation in drivers (imo the crtc helper framework is holy inadequate for this safe for the simplest of drivers) and in testing the ioctl interfaces exhaustively.
Especially the testing is very important, since the entire design hinges on the test-flag to make complex configuration constraints discoverable at run-time. I think we need a few tools that random-walk the configuration space and check whether any configuration that returns
-EINVALin the test mode actually fails (and vice-versa), maybe excluding any other failures in the real modeset like-EIO(e.g. due to some stupid dp link failing to properly lock onto the stream).Cheers, Daniel
--
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
Re: [RFC][PATCH 08/10] WIP: drm: Atomic modeset ioctl
Quoted 23 lines · Rob Clark
yeah, nuclear-pageflip would be associated only w/ a single crtc. Actually I was kinda assuming atomic-modeset was too.. ie. moving a plane from one crtc to another would be two ioctls, one to remove it from first crtc, one to add to the other. Although maybe one big ioctl is better.
I do think there is a bit of a grey area between the two. Ie. enabling/disabling a crtc, or changing what
encoder->connectorit is hooked to might be taking several vblank cycles, and is a relatively infrequent operation so ok to block. Enabling/disabling a plane could be much more frequent and should not block. Returning EINVAL or EBUSY in the transient case where it isn't ready quite yet seems like a good approach.. EBUSY might be better for "it might succeed if you try again in next vblank" and EINVAL for "it won't ever work with current setup, don't bother trying again".Infrequent, can be slow:
+ enabling/disabling a new outputSemi-frequent, should not block but
-EBUSYok:
+ enabling/disabling a plane
+ resizing a plane
Quoted 6 lines
More frequent, should not block, should not need extra "test" ioctl step, but should just work
+ page flip, update plane positionSo for that middle group, I'm a bit fuzzy on where those operations should fit in..
My idea is that the nuclear pageflip should support those since they only affect a single crtc. The compositor would simply assume it will work out, and the kernel can then succeed, or return either the transient or definite -EINVAL if it doesn't work out. In the later case the compositor can retry in the next frame (and fall back to gpu compositing for the current one).
[snip]
Quoted 15 lines
Quoted 6 lines
- Also a rather practical one: The lack of nuclear pageflip is the reason that Wayland/Weston can't use sprites atm (since
set_planeis can be synchronous and can't be synced with a pageflip). Kristian therefore wants the atomic modeset (which I think is much more invasive) not to stall the nuclear pageflip support. And the implementation effort is imo really a big difference: For i915.ko I expect the nuclear pageflip toQuoted 8 lines
mostly boil down to wiring up async plane/cursor updates through the latch register (with keeping all the other setup code around since we only allow at most one outstanding pageflip per crtc currently anyway) and wiring that up with the existing crtc pageflip handler. atomic modeset otoh requires an invasive rewrite of the driver code to properly handle these shared resources (and support the test mode). The beginning of that is happening with the modeset rework, but that's just the first step.
Quoted 3 lines
Hmm, I was thinking Ville's atomic fxns would be useful, but maybe I can still bits from that and try and put nuclear-pageflip beneath atomic-modeset in the stack.
At least in i915 I expect that the atomic modeset and the nuclear pageflip would take rather different paths. I'm not even sure whether we should support enabling planes in the amotic modeset (userspace can always composite the first frame after a modeset with the gpu) and handle enabling planes with only the nuclear pageflip.
I guess we /could/ add a few things to the crtc helper code to facilitate drivers using them to support atomic modeset. I'm thinking of a simple ->check callback at the beginning, which checks whether the global configuration can be supported. This checking would be in addition to the ->mode_fixup checking we already have in place at the encoder/crtc layer.
Then we could add a simple atomic_modeset implementation for using these interfaces.
For the nuclear pageflip I guess we'll just add a new crtc interface (not in the helper func pointer) which gets all the new parameters and let drivers sort things out. Since the flip needs to happen synced to the same vblank for everything, I don't see how we could compose this without some in-depth hw knowledge (which only the driver has) in some generic framework. And we do not yet support pageflip on planes (at least not in full glory with drm events and timestamps) anyway.
Cheers, Daniel
Signature · 2 lines
Daniel Vetter [email protected] - +41 (0) 79 364 57 48 - http://blog.ffwll.ch
Re: [RFC][PATCH 08/10] WIP: drm: Atomic modeset ioctl
Quoted 31 lines · Daniel Vetter
Quoted 23 lines · Rob Clark
yeah, nuclear-pageflip would be associated only w/ a single crtc. Actually I was kinda assuming atomic-modeset was too.. ie. moving a plane from one crtc to another would be two ioctls, one to remove it from first crtc, one to add to the other. Although maybe one big ioctl is better.
I do think there is a bit of a grey area between the two. Ie. enabling/disabling a crtc, or changing what
encoder->connectorit is hooked to might be taking several vblank cycles, and is a relatively infrequent operation so ok to block. Enabling/disabling a plane could be much more frequent and should not block. Returning EINVAL or EBUSY in the transient case where it isn't ready quite yet seems like a good approach.. EBUSY might be better for "it might succeed if you try again in next vblank" and EINVAL for "it won't ever work with current setup, don't bother trying again".Infrequent, can be slow:
+ enabling/disabling a new outputSemi-frequent, should not block but
-EBUSYok:
+ enabling/disabling a plane
+ resizing a planeQuoted 6 lines
More frequent, should not block, should not need extra "test" ioctl step, but should just work
+ page flip, update plane positionSo for that middle group, I'm a bit fuzzy on where those operations should fit in..
Quoted 6 lines
My idea is that the nuclear pageflip should support those since they only affect a single crtc. The compositor would simply assume it will work out, and the kernel can then succeed, or return either the transient or definite
-EINVALif it doesn't work out. In the later case the compositor can retry in the next frame (and fall back to gpu compositing for the current one).
hmm, but this would imply that the nuclear pageflip must also have a 'test' step.. because the compositor needs to know whether or not it will work, *then* kick rendering, and *then* issue the actual pageflip.
But OTOH, some simple things like just flipping or perhaps flipping+moving should not need a test step. I guess userspace could just know that certain operations don't need a test step. Seems a bit weird, though.
Quoted 21 lines
[snip]
Quoted 15 lines
Quoted 6 lines
- Also a rather practical one: The lack of nuclear pageflip is the reason that Wayland/Weston can't use sprites atm (since
set_planeis can be synchronous and can't be synced with a pageflip). Kristian therefore wants the atomic modeset (which I think is much more invasive) not to stall the nuclear pageflip support. And the implementation effort is imo really a big difference: For i915.ko I expect the nuclear pageflip toQuoted 8 lines
mostly boil down to wiring up async plane/cursor updates through the latch register (with keeping all the other setup code around since we only allow at most one outstanding pageflip per crtc currently anyway) and wiring that up with the existing crtc pageflip handler. atomic modeset otoh requires an invasive rewrite of the driver code to properly handle these shared resources (and support the test mode). The beginning of that is happening with the modeset rework, but that's just the first step.
Quoted 3 lines
Hmm, I was thinking Ville's atomic fxns would be useful, but maybe I can still bits from that and try and put nuclear-pageflip beneath atomic-modeset in the stack.
Quoted 5 lines
At least in i915 I expect that the atomic modeset and the nuclear pageflip would take rather different paths. I'm not even sure whether we should support enabling planes in the amotic modeset (userspace can always composite the first frame after a modeset with the gpu) and handle enabling planes with only the nuclear pageflip.
hmm, ok, yeah.. I guess we could just make nuclear_page_flip a fxnptr on the crtc funcs.
I suppose I don't mind one way or another about the enabling/disabling planes. It seems ok to render first frame w/ gpu, so if it simplifies things I guess it is ok.
Quoted 10 lines
I guess we /could/ add a few things to the crtc helper code to facilitate drivers using them to support atomic modeset. I'm thinking of a simple ->check callback at the beginning, which checks whether the global configuration can be supported. This checking would be in addition to the ->mode_fixup checking we already have in place at the encoder/crtc layer.
Then we could add a simple
atomic_modesetimplementation for using these interfaces.
Quoted 7 lines
For the nuclear pageflip I guess we'll just add a new crtc interface (not in the helper func pointer) which gets all the new parameters and let drivers sort things out. Since the flip needs to happen synced to the same vblank for everything, I don't see how we could compose this without some in-depth hw knowledge (which only the driver has) in some generic framework. And we do not yet support pageflip on planes (at least not in full glory with drm events and timestamps) anyway.
Right, I was thinking to start without helper.. it is easy enough to add helpers later if there are some common patterns emerging between the different drivers.
BR,
-R
Quoted 4 lines
Cheers, Daniel
--
Daniel Vetter
[email protected] - +41 (0) 79 364 57 48 - http://blog.ffwll.ch
RFC PATCH 9/10 drm/i915: Split clipping and checking from update_plane hook
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Split the update_plane() codepath into two separate steps. The first step checkis and clips the plane, and the second step actually commits the changes to the hardware. This allows the atomic modesetting code to perform all checks before clobering hardware state.
The update_plane() hook is reduced to a thin wrapper calling both check and commit functions.
Buffer (un)pinning is still being performed in the commit step. This needs to be changed as well, so that the atomic modesetting code can try to pin all new buffers before touching the hardware.
--- drivers/gpu/drm/i915/intel_drv.h | 15 +- drivers/gpu/drm/i915/intel_sprite.c | 372 ++++++++++++++++++++++------------- 2 files changed, 249 insertions(+), 138 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +10 -5
@@ -187,6 +187,15 @@ struct intel_crtc {struct intel_pch_pll *pch_pll; }; +struct intel_plane_coords { +/* disabled or fully clipped? */ +bool visible; +/* coordinates clipped against pipe dimensions */ +int32_t crtc_x, crtc_y; +uint32_t crtc_w, crtc_h; +uint32_t src_x, src_y, src_w, src_h; +}; +struct intel_plane {struct drm_plane base;enum pipe pipe;
@@ -196,11 +205,7 @@ struct intel_plane {u32 lut_r[1024 ], lut_g[1024 ], lut_b[1024 ];void (*update_plane)(struct drm_plane *plane,struct drm_framebuffer *fb, -struct drm_i915_gem_object *obj, -int crtc_x,int crtc_y, -unsigned int crtc_w,unsigned int crtc_h, -uint32_t x,uint32_t y, -uint32_t src_w,uint32_t src_h); +const struct intel_plane_coords *clip);void (*disable_plane)(struct drm_plane *plane);int (*update_colorkey)(struct drm_plane *plane,struct drm_intel_sprite_colorkey *key);
drivers/gpu/drm/i915/intel_sprite.c +239 -133
437 lines not on this page · raw message
Signature · 6 lines
1.7.3.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC PATCH 10/10 WIP drm/i915: "Atomic" modeset test implementation
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Second attempt at the atomic modeset implementation. This versions does things in a way that's closer to the drm_crtc_helper way. Not exactly pretty, but there's too much code depending on that design to change it.
--- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/intel_atomic.c | 1101 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_display.c | 7 + 3 files changed, 1109 insertions(+), 0 deletions(-) create mode 100644 drivers/gpu/drm/i915/intel_atomic.c
drivers/gpu/drm/i915/Makefile +1 -0
@@ -15,6 +15,7 @@ i915-y := i915_drv.o i915_dma.o i915_irq.o \ i915_gem_tiling.o \ i915_sysfs.o \ i915_trace_points.o \ + intel_atomic.o \ intel_display.o \ intel_crt.o \ intel_lvds.o \
drivers/gpu/drm/i915/intel_atomic.c new file +1101 -0
1,101 lines not on this page · raw message
drivers/gpu/drm/i915/intel_display.c +7 -0
@@ -7053,6 +7053,9 @@ void intel_modeset_init_hw(struct drm_device *dev)ivb_pch_pwm_override (dev); } +void intel_atomic_init (struct drm_device *dev); +void intel_atomic_fini (struct drm_device *dev); +void intel_modeset_init (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;
@@ -7107,6 +7110,8 @@ void intel_modeset_init(struct drm_device *dev)INIT_WORK (&dev_priv->idle_work, intel_idle_update);setup_timer (&dev_priv->idle_timer, intel_gpu_idle_timer, (unsigned long )dev); + +intel_atomic_init (dev); }void intel_modeset_gem_init (struct drm_device *dev)
@@ -7122,6 +7127,8 @@ void intel_modeset_cleanup(struct drm_device *dev)struct drm_crtc *crtc;struct intel_crtc *intel_crtc; +intel_atomic_fini (dev); +drm_kms_helper_poll_fini (dev);mutex_lock (&dev->struct_mutex);
Signature · 6 lines
1.7.3.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · On Wed, 27 Jun 2012 13:24:02 +0300 [email protected] wrote:
Second version of the atomic mode setting work. Still very much work in progress.
I decided that I can't afford to fight the
drm_crtc_helperarchitecture due to the sheer amount of driver code depending on it. So I changed the code to do things in way that more closely matchesdrm_crtc_helper.
:(
Quoted 8 lines
Next I'll be moving the buffer pinning to happen before any hw state is clobbered. This will avoid having to do actual rollbacks when pinning fails. And a similar treatment needs to be done to the PLL calculations (those should be done before buffer pinning).
I didn't re-post all the i915 specific bits I have in my tree since those didn't really change. I pushed the whole work to the
drm_atomic_2branch at https://gitorious.org/vsyrjala/linux.
OTOH introducing an atomic alternative to the helper stuff and moving drivers over would probably end up looking a lot nicer. But there's no doubt that's a huge chunk of work...
The other thing I'm worried about with atomic mode setting is handling the legacy case properly. We'll still need to handle apps that want to change one CRTC at a time without altering the state of other CRTCs. In an atomic context, drivers should be able to assume they can shut anything off that doesn't come in as part of the atomic state, which means when we build a compat atomic setup, we'll need to read the current state of any existing objects and pass them in to the driver...
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
Quoted 3 lines · Jesse Barnes
The other thing I'm worried about with atomic mode setting is handling the legacy case properly. We'll still need to handle apps that want to change one CRTC at a time without altering the state of other CRTCs.
Fortunately that's not true, you can flag-day it (per drm device even, if we want). If the first thing userspace asks for is atomic modeset then you simply disallow subsequent non-atomic modesets, and the reverse. Userspace code will need to grow atomic support anyway, so can simply treat -EINVAL from trying it as meaning "no kernel support, revert to the older thing".
This does mean you have to update all of userspace to do the new call instead of the old one, but that's fine, there's only a handful of clients for this API.
- ajax
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerQuoted 13 lines · Adam Jackson
Quoted 3 lines · Jesse Barnes
The other thing I'm worried about with atomic mode setting is handling the legacy case properly. We'll still need to handle apps that want to change one CRTC at a time without altering the state of other CRTCs.
Fortunately that's not true, you can flag-day it (per drm device even, if we want). If the first thing userspace asks for is atomic modeset then you simply disallow subsequent non-atomic modesets, and the reverse. Userspace code will need to grow atomic support anyway, so can simply treat
-EINVALfrom trying it as meaning "no kernel support, revert to the older thing".
Quoted 4 lines
This does mean you have to update all of userspace to do the new call instead of the old one, but that's fine, there's only a handful of clients for this API.
You'll also need to handles cases like render nodes where we split resources for multi-seat on one gpu.
Dave.
Quoted 18 lines · Jesse Barnes
Quoted 7 lines · On Wed, 27 Jun 2012 13:24:02 +0300 [email protected] wrote:
Second version of the atomic mode setting work. Still very much work in progress.
I decided that I can't afford to fight the
drm_crtc_helperarchitecture due to the sheer amount of driver code depending on it. So I changed the code to do things in way that more closely matchesdrm_crtc_helper.:(
Quoted 5 lines
Next I'll be moving the buffer pinning to happen before any hw state is clobbered. This will avoid having to do actual rollbacks when pinning fails. And a similar treatment needs to be done to the PLL calculations (those should be done before buffer pinning).
Quoted 7 lines
Quoted 3 lines
I didn't re-post all the i915 specific bits I have in my tree since those didn't really change. I pushed the whole work to the
drm_atomic_2branch at https://gitorious.org/vsyrjala/linux.OTOH introducing an atomic alternative to the helper stuff and moving drivers over would probably end up looking a lot nicer. But there's no doubt that's a huge chunk of work...
I'm thinking that it should be doable. Well, at least for all the "core" features, but I'm not quite sure how it would handle all driver specific properties in a nice way. Basically what I have now in intel_atomic.c could become the new helper, but then it needs somehow to defer to the driver for some of the props.
So either the driver needs to collect the state for those somehow, or we have the core do it the same way as for other objects, ie. overwrite the object state with the new values as we go on, and then roll back later if necessary. But then we potentially need to save/restore all properties in the beginning and end of the operation, or we could try to do it in some lazy fashion.
Quoted 7 lines
The other thing I'm worried about with atomic mode setting is handling the legacy case properly. We'll still need to handle apps that want to change one CRTC at a time without altering the state of other CRTCs. In an atomic context, drivers should be able to assume they can shut anything off that doesn't come in as part of the atomic state, which means when we build a compat atomic setup, we'll need to read the current state of any existing objects and pass them in to the driver...
My current code collects the current state in the beginning (or rather it saves the state of all the objects in the beginning) and starts to modify the current state of the objects as new values are read in by the ioctl handler. Anything not part of the atomic modeset is left untouched.
Signature · 2 lines
Ville Syrjälä Intel OTC