Atomic modeset/pageflip update
Subsystems (3)
RFC PATCH 1/1 Atomic modeset/pageflip update
Here's another set of atomic modeset and pageflip patches. I just skipped spamming the list with all the patches that contain the gritty details for now. These three provide an eagle eye view of the whole thing. The full series can be found here [1].
The accompanying libdrm stuff is here [2].
So what are the significant changes since the last time:
- Pass the display modes as blobs as opposed to mode object IDs
- Fixed blob passing (it was simply broken in my earlier patches)
- Add completion events
- Add the non-blocking flag
- Clean up the history a bit to make the patches easier on the eye
Unfortunately the whole thing is still based on the pre i915 modeset rework code. So porting the modesetting side over to the current i915 code is one two bigger tasks that I have left. The other is implementing non-blocking synchronization with the GPU.
[1] https://gitorious.org/vsyrjala/linux/commits/drm_atomic_9
[2] https://gitorious.org/vsyrjala/drm/commits/drm_atomic_7
RFC PATCH 1/1 drm/i915: Implement atomic modesetting
From: Ville Syrjälä <[email protected]>
Implement the atomic modeset operations.
TODO: need to rewrite this for the new intel modeset code
--- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/intel_atomic.c | 1462 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_display.c | 7 + 3 files changed, 1470 insertions(+), 0 deletions(-) create mode 100644 drivers/gpu/drm/i915/intel_atomic.c
drivers/gpu/drm/i915/Makefile +1 -0
@@ -16,6 +16,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 +1462 -0
1,462 lines not on this page · raw message
drivers/gpu/drm/i915/intel_display.c +7 -0
@@ -43,6 +43,9 @@#define HAS_eDP (intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP)) +void intel_atomic_init (struct drm_device *dev); +void intel_atomic_fini (struct drm_device *dev); +bool intel_pipe_has_type (struct drm_crtc *crtc,int type);static void intel_increase_pllclock (struct drm_crtc *crtc);static void intel_crtc_update_cursor (struct drm_crtc *crtc,bool on);
@@ -7014,6 +7017,8 @@ static void intel_setup_outputs(struct drm_device *dev)intel_encoder_clones (dev, encoder->clone_mask); } +intel_atomic_init (dev); +/* disable all the possible outputs/crtcs before entering KMS mode */ drm_helper_disable_unused_functions (dev);
@@ -7484,6 +7489,8 @@ void intel_modeset_cleanup(struct drm_device *dev)del_timer_sync (&dev_priv->idle_timer);cancel_work_sync (&dev_priv->idle_work); +intel_atomic_fini (dev); +drm_mode_config_cleanup (dev); }
Signature · 6 lines
1.7.8.6 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC PATCH 1/1 drm: Atomic modeset ioctl
In reply to [email protected]From: Ville Syrjälä <[email protected]>
The atomic modeset ioctl cna be used to push any number of new values for object properties. The driver can then check the full device configuration as single unit, and try to apply the changes atomically.
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.
The caller can demand non-blocking operation from the ioctl, and if the driver can't satisfy that requirement an error will be returned.
The caller can also request to receive asynchronous completion events after the operation has reached the hardware. An event is sent for each object specified by the caller, whether or not the actual state of that object changed. Each event also carries a framebuffer ID, which indicates to user space that the specified object is no longer accessing that framebuffer.
TODO: detailed error reporting?
--- drivers/gpu/drm/drm_crtc.c | 146 ++++++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_drv.c | 1 + include/drm/drm.h | 12 ++++ include/drm/drmP.h | 8 +++ include/drm/drm_crtc.h | 13 ++++ include/drm/drm_mode.h | 16 +++++ 6 files changed, 196 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_crtc.c +146 -0
@@ -4162,3 +4162,149 @@ 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_MODE_ATOMIC_TEST_ONLY |DRM_MODE_ATOMIC_EVENT |DRM_MODE_ATOMIC_NONBLOCK )) +return -EINVAL ; + +/* can't test and expect an event at the same time. */ +if (arg->flags &DRM_MODE_ATOMIC_TEST_ONLY && arg->flags &DRM_MODE_ATOMIC_EVENT ) +return -EINVAL ; + +mutex_lock (&dev->mode_config.mutex); + + state = dev->driver->atomic_funcs->begin (dev, file_priv, arg->flags, arg->user_data); +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) { +uint64_t blob_ptr; + +if (get_user (blob_ptr, blob_values_ptr + copied_blobs)) { + ret = -EFAULT ; + goto out; + } + + blob_data =kmalloc (prop_value,GFP_KERNEL ); +if (!blob_data) { + ret = -ENOMEM ; + goto out; + } + +if (copy_from_user (blob_data, (void __user *)(unsigned long )blob_ptr, prop_value)) { +kfree (blob_data); + ret = -EFAULT ; + goto out; + } + } + +/* User space sends the blob pointer even if we don't use it (length==0). */ +if (prop->flags &DRM_MODE_PROP_BLOB ) + 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_MODE_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 +12 -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
@@ -763,6 +764,7 @@ struct drm_event {#define DRM_EVENT_VBLANK 0x01#define DRM_EVENT_FLIP_COMPLETE 0x02 +#define DRM_EVENT_ATOMIC_COMPLETE 0x03struct drm_event_vblank {struct drm_event base;
@@ -773,6 +775,16 @@ struct drm_event_vblank {__u32 reserved; }; +struct drm_event_atomic { +struct drm_event base; +__u64 user_data; +__u32 tv_sec; +__u32 tv_usec; +__u32 sequence; +__u32 obj_id; +__u32 old_fb_id; +}; +#define DRM_CAP_DUMB_BUFFER 0x1#define DRM_CAP_VBLANK_HIGH_CRTC 0x2#define DRM_CAP_DUMB_PREFERRED_DEPTH 0x3
include/drm/drmP.h +8 -0
@@ -957,6 +957,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
@@ -1050,6 +1052,12 @@ struct drm_pending_vblank_event {struct drm_event_vblank event; }; +struct drm_pending_atomic_event { +struct drm_pending_event base; +int pipe; +struct drm_event_atomic event; +}; +/** * DRM device structure. This structure represent a complete card that * may contain multiple heads.
include/drm/drm_crtc.h +13 -0
@@ -1071,6 +1071,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);
@@ -1111,4 +1113,15 @@ 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,struct drm_file *file, +uint32_t flags,uint64_t user_data); +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 +16 -0
@@ -459,4 +459,20 @@ struct drm_mode_destroy_dumb { uint32_t handle; }; +#define DRM_MODE_ATOMIC_TEST_ONLY (1<<0) +#define DRM_MODE_ATOMIC_EVENT (1<<1) +#define DRM_MODE_ATOMIC_NONBLOCK (1<<2) + +/* 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; +__u64 user_data; +}; +#endif
Signature · 6 lines
1.7.8.6 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC PATCH 1/1 drm/i915: Add atomic page flip support
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Utilize drm_flip to implement "atomic page flip". When involving multiple planes on one pipe, the operations on the planes must be synchronized via software since the hardware doesn't provide the means. drm_flip is used to make that happen, and to track the progress of the flip operations.
--- drivers/gpu/drm/i915/i915_dma.c | 5 + drivers/gpu/drm/i915/i915_drv.h | 4 + drivers/gpu/drm/i915/i915_irq.c | 18 +- drivers/gpu/drm/i915/intel_atomic.c | 813 +++++++++++++++++++++++++++++++++- drivers/gpu/drm/i915/intel_display.c | 2 + drivers/gpu/drm/i915/intel_drv.h | 6 + 6 files changed, 832 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +5 -0
@@ -1762,6 +1762,8 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file)idr_init (&file_priv->context_idr); +INIT_LIST_HEAD (&file_priv->pending_flips); +return 0 ; }
@@ -1792,10 +1794,13 @@ void i915_driver_lastclose(struct drm_device * dev)i915_dma_cleanup (dev); } +void intel_atomic_free_events (struct drm_device *dev,struct drm_file *file); +void i915_driver_preclose (struct drm_device * dev,struct drm_file *file_priv) {i915_gem_context_close (dev, file_priv);i915_gem_release (dev, file_priv); +intel_atomic_free_events (dev, file_priv); }void i915_driver_postclose (struct drm_device *dev,struct drm_file *file)
drivers/gpu/drm/i915/i915_drv.h +4 -0
@@ -36,6 +36,7 @@#include <linux/io-mapping.h> #include <linux/i2c.h> #include <linux/i2c-algo-bit.h> +#include <drm/drm_flip.h> #include <drm/intel-gtt.h> #include <linux/backlight.h> #include <linux/intel-iommu.h>
@@ -845,6 +846,8 @@ typedef struct drm_i915_private {struct work_struct parity_error_work;bool hw_contexts_disabled;uint32_t hw_context_size; + +struct drm_flip_driver flip_driver; } drm_i915_private_t;/* Iterate over initialised rings */
@@ -1055,6 +1058,7 @@ struct drm_i915_file_private {struct list_head request_list; } mm;struct idr context_idr; +struct list_head pending_flips; };#define INTEL_INFO (dev) (((struct drm_i915_private *) (dev)->dev_private)->info)
drivers/gpu/drm/i915/i915_irq.c +14 -4
@@ -37,6 +37,8 @@#include "i915_trace.h" #include "intel_drv.h" +void intel_atomic_handle_vblank (struct drm_device *dev,int pipe); +/* For display hotplug interrupt */ static void ironlake_enable_display_irq (drm_i915_private_t *dev_priv,u32 mask)
@@ -547,8 +549,10 @@ static irqreturn_t valleyview_irq_handler(DRM_IRQ_ARGS)spin_unlock_irqrestore (&dev_priv->irq_lock, irqflags);for_each_pipe (pipe) { -if (pipe_stats[pipe] &PIPE_VBLANK_INTERRUPT_STATUS ) +if (pipe_stats[pipe] &PIPE_VBLANK_INTERRUPT_STATUS ) {drm_handle_vblank (dev, pipe); +intel_atomic_handle_vblank (dev, pipe); + }if (pipe_stats[pipe] &PLANE_FLIPDONE_INT_STATUS_VLV ) {intel_prepare_page_flip (dev, pipe);
@@ -685,8 +689,10 @@ static irqreturn_t ivybridge_irq_handler(DRM_IRQ_ARGS)intel_prepare_page_flip (dev, i);intel_finish_page_flip_plane (dev, i); } -if (de_iir & (DE_PIPEA_VBLANK_IVB << (5 * i))) +if (de_iir & (DE_PIPEA_VBLANK_IVB << (5 * i))) {drm_handle_vblank (dev, i); +intel_atomic_handle_vblank (dev, i); + } }/* check event from PCH */
@@ -778,11 +784,15 @@ static irqreturn_t ironlake_irq_handler(DRM_IRQ_ARGS)intel_finish_page_flip_plane (dev,1 ); } -if (de_iir &DE_PIPEA_VBLANK ) +if (de_iir &DE_PIPEA_VBLANK ) {drm_handle_vblank (dev,0 ); +intel_atomic_handle_vblank (dev,0 ); + } -if (de_iir &DE_PIPEB_VBLANK ) +if (de_iir &DE_PIPEB_VBLANK ) {drm_handle_vblank (dev,1 ); +intel_atomic_handle_vblank (dev,1 ); + }/* check event from PCH */ if (de_iir &DE_PCH_EVENT ) {
drivers/gpu/drm/i915/intel_atomic.c +801 -12
911 lines not on this page · raw message
drivers/gpu/drm/i915/intel_display.c +2 -0
@@ -3351,6 +3351,7 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc)return ;intel_crtc_wait_for_pending_flips (crtc); +drm_flip_helper_clear (&intel_crtc->flip_helper);drm_vblank_off (dev, pipe);intel_crtc_update_cursor (crtc, false);
@@ -3522,6 +3523,7 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc)/* Give the overlay scaler a chance to disable if it's on this pipe */ intel_crtc_wait_for_pending_flips (crtc); +drm_flip_helper_clear (&intel_crtc->flip_helper);drm_vblank_off (dev, pipe);intel_crtc_dpms_overlay (intel_crtc, false);intel_crtc_update_cursor (crtc, false);
drivers/gpu/drm/i915/intel_drv.h +6 -0
@@ -31,6 +31,7 @@#include "drm_crtc.h" #include "drm_crtc_helper.h" #include "drm_fb_helper.h" +#include "drm_flip.h" #define _wait_for (COND ,MS ,W ) ({ \ unsigned long timeout__ = jiffies + msecs_to_jiffies(MS); \
@@ -208,6 +209,10 @@ struct intel_crtc {struct intel_pch_pll *pch_pll;struct intel_plane_regs primary_regs; + +struct drm_flip_helper flip_helper; +wait_queue_head_t vbl_wait; +bool vbl_received; };struct intel_plane_coords {
@@ -234,6 +239,7 @@ struct intel_plane { struct drm_intel_sprite_colorkey *key);void (*get_colorkey)(struct drm_plane *plane,struct drm_intel_sprite_colorkey *key); +struct drm_flip_helper flip_helper; };struct intel_watermark_params {
Signature · 6 lines
1.7.8.6 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel