From 4077798484459a2eced2050045099a466ecb618a Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 15 Jul 2016 09:31:11 +0100 Subject: drm/vgem: Attach sw fences to exported vGEM dma-buf (ioctl) vGEM buffers are useful for passing data between software clients and hardware renders. By allowing the user to create and attach fences to the exported vGEM buffers (on the dma-buf), the user can implement a deferred renderer and queue hardware operations like flipping and then signal the buffer readiness (i.e. this allows the user to schedule operations out-of-order, but have them complete in-order). This also makes it much easier to write tightly controlled testcases for dma-buf fencing and signaling between hardware drivers. v2: Don't pretend the fences exist in an ordered timeline, but allocate a separate fence-context for each fence so that the fences are unordered. v3: Make the debug output more interesting, and show the signaled status. v4: Automatically signal the fence to prevent userspace from indefinitely hanging drivers. Testcase: igt/vgem_basic/dmabuf-fence Testcase: igt/vgem_slow/nohang Signed-off-by: Chris Wilson Cc: Sean Paul Cc: Zach Reizner Cc: Gustavo Padovan Cc: Daniel Vetter Acked-by: Zach Reizner Signed-off-by: Daniel Vetter Link: http://patchwork.freedesktop.org/patch/msgid/1468571471-12610-1-git-send-email-chris@chris-wilson.co.uk --- include/uapi/drm/vgem_drm.h | 62 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 include/uapi/drm/vgem_drm.h (limited to 'include') diff --git a/include/uapi/drm/vgem_drm.h b/include/uapi/drm/vgem_drm.h new file mode 100644 index 000000000000..bf66f5db6da8 --- /dev/null +++ b/include/uapi/drm/vgem_drm.h @@ -0,0 +1,62 @@ +/* + * Copyright 2016 Intel Corporation + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#ifndef _UAPI_VGEM_DRM_H_ +#define _UAPI_VGEM_DRM_H_ + +#include "drm.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +/* Please note that modifications to all structs defined here are + * subject to backwards-compatibility constraints. + */ +#define DRM_VGEM_FENCE_ATTACH 0x1 +#define DRM_VGEM_FENCE_SIGNAL 0x2 + +#define DRM_IOCTL_VGEM_FENCE_ATTACH DRM_IOWR( DRM_COMMAND_BASE + DRM_VGEM_FENCE_ATTACH, struct drm_vgem_fence_attach) +#define DRM_IOCTL_VGEM_FENCE_SIGNAL DRM_IOW( DRM_COMMAND_BASE + DRM_VGEM_FENCE_SIGNAL, struct drm_vgem_fence_signal) + +struct drm_vgem_fence_attach { + __u32 handle; + __u32 flags; +#define VGEM_FENCE_WRITE 0x1 + __u32 out_fence; + __u32 pad; +}; + +struct drm_vgem_fence_signal { + __u32 fence; + __u32 flags; +}; + +#if defined(__cplusplus) +} +#endif + +#endif /* _UAPI_VGEM_DRM_H_ */ -- cgit v1.2.3 From 6100598c4a2772bfc7a7a6518a4fea377337952b Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 13 Jul 2016 17:39:07 +0100 Subject: drm: Unexport drm_connector_unregister_all() This has now been removed from all drivers as it is performed centrally as a part of device unregistration for modesetting drivers. With the last user gone, we can unexport it from the DRM module. That requires us to move the code slightly to avoid the need for a forward declaration. Signed-off-by: Chris Wilson Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel@lists.freedesktop.org Reviewed-by: Sean Paul Signed-off-by: Daniel Vetter Link: http://patchwork.freedesktop.org/patch/msgid/1468427947-28037-2-git-send-email-chris@chris-wilson.co.uk --- include/drm/drm_crtc.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include') diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 9e6ab4a0c274..6b9df1137818 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -2587,9 +2587,6 @@ static inline unsigned drm_connector_index(struct drm_connector *connector) return connector->connector_id; } -/* helpers to {un}register all connectors from sysfs for device */ -extern void drm_connector_unregister_all(struct drm_device *dev); - extern __printf(5, 6) int drm_encoder_init(struct drm_device *dev, struct drm_encoder *encoder, -- cgit v1.2.3 From 96094081ae9586b7b99373814e81788448ff127e Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Fri, 15 Jul 2016 21:47:59 +0200 Subject: drm/doc: Add kerneldoc for @index Was forgotten when adding them all over. 0-day should complain about new missing kernel-doc, not sure why that wasn't caught/fixed. v2: Clarify that @index is invariant, as discussed with Chris Wilson. Cc: Chris Wilson Reviewed-by: Chris Wilson Signed-off-by: Daniel Vetter Link: http://patchwork.freedesktop.org/patch/msgid/1468612088-9721-2-git-send-email-daniel.vetter@ffwll.ch --- include/drm/drm_crtc.h | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 6b9df1137818..f60d34a43c5b 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -782,7 +782,10 @@ struct drm_crtc { struct drm_plane *primary; struct drm_plane *cursor; - /* position inside the mode_config.list, can be used as a [] idx */ + /** + * @index: Position inside the mode_config.list, can be used as an array + * index. It is invariant over the lifetime of the CRTC. + */ unsigned index; /* position of cursor plane on crtc */ @@ -1209,7 +1212,10 @@ struct drm_encoder { char *name; int encoder_type; - /* position inside the mode_config.list, can be used as a [] idx */ + /** + * @index: Position inside the mode_config.list, can be used as an array + * index. It is invariant over the lifetime of the encoder. + */ unsigned index; uint32_t possible_crtcs; @@ -1710,7 +1716,10 @@ struct drm_plane { enum drm_plane_type type; - /* position inside the mode_config.list, can be used as a [] idx */ + /** + * @index: Position inside the mode_config.list, can be used as an array + * index. It is invariant over the lifetime of the plane. + */ unsigned index; const struct drm_plane_helper_funcs *helper_private; @@ -2318,8 +2327,6 @@ struct drm_mode_config_funcs { * @fb_lock: mutex to protect fb state and lists * @num_fb: number of fbs available * @fb_list: list of framebuffers available - * @num_connector: number of connectors on this device - * @connector_list: list of connector objects * @num_encoder: number of encoders on this device * @encoder_list: list of encoder objects * @num_overlay_plane: number of overlay planes on this device @@ -2394,8 +2401,17 @@ struct drm_mode_config { int num_fb; struct list_head fb_list; + /** + * @num_connector: Number of connectors on this device. + */ int num_connector; + /** + * @connector_ida: ID allocator for connector indices. + */ struct ida connector_ida; + /** + * @connector_list: List of connector objects. + */ struct list_head connector_list; int num_encoder; struct list_head encoder_list; -- cgit v1.2.3 From 9a6bc03cd63479a40757865e5ff2e510fc2dcdb9 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Fri, 15 Jul 2016 21:48:00 +0200 Subject: drm/doc: document all the properties in drm_mode_config I'm fed up with the warning noise from kernel-doc. Aside: I stumbled over dirty_info_property, which is only set by udl and qxl. But we have a _lot_ more drivers implementing a dirty callback on framebuffers. Not entirely sure what the ABI is supposed to be here, but it seems confusing for sure. Acked-by: Chris Wilson Signed-off-by: Daniel Vetter Link: http://patchwork.freedesktop.org/patch/msgid/1468612088-9721-3-git-send-email-daniel.vetter@ffwll.ch --- include/drm/drm_crtc.h | 196 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 180 insertions(+), 16 deletions(-) (limited to 'include') diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index f60d34a43c5b..f8ba5aab5d28 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -2348,18 +2348,8 @@ struct drm_mode_config_funcs { * @property_blob_list: list of all the blob property objects * @blob_lock: mutex for blob property allocation and management * @*_property: core property tracking - * @degamma_lut_property: LUT used to convert the framebuffer's colors to linear - * gamma - * @degamma_lut_size_property: size of the degamma LUT as supported by the - * driver (read-only) - * @ctm_property: Matrix used to convert colors after the lookup in the - * degamma LUT - * @gamma_lut_property: LUT used to convert the colors, after the CSC matrix, to - * the gamma space of the connected screen (read-only) - * @gamma_lut_size_property: size of the gamma LUT as supported by the driver * @preferred_depth: preferred RBG pixel depth, used by fb helpers * @prefer_shadow: hint to userspace to prefer shadow-fb rendering - * @async_page_flip: does this device support async flips on the primary plane? * @cursor_width: hint to userspace for max cursor width * @cursor_height: hint to userspace for max cursor height * @helper_private: mid-layer private data @@ -2446,64 +2436,238 @@ struct drm_mode_config { /* pointers to standard properties */ struct list_head property_blob_list; + /** + * @edid_property: Default connector property to hold the EDID of the + * currently connected sink, if any. + */ struct drm_property *edid_property; + /** + * @dpms_property: Default connector property to control the + * connector's DPMS state. + */ struct drm_property *dpms_property; + /** + * @path_property: Default connector property to hold the DP MST path + * for the port. + */ struct drm_property *path_property; + /** + * @tile_property: Default connector property to store the tile + * position of a tiled screen, for sinks which need to be driven with + * multiple CRTCs. + */ struct drm_property *tile_property; + /** + * @plane_type_property: Default plane property to differentiate + * CURSOR, PRIMARY and OVERLAY legacy uses of planes. + */ struct drm_property *plane_type_property; + /** + * @rotation_property: Optional property for planes or CRTCs to specifiy + * rotation. + */ struct drm_property *rotation_property; + /** + * @prop_src_x: Default atomic plane property for the plane source + * position in the connected &drm_framebuffer. + */ struct drm_property *prop_src_x; + /** + * @prop_src_y: Default atomic plane property for the plane source + * position in the connected &drm_framebuffer. + */ struct drm_property *prop_src_y; + /** + * @prop_src_w: Default atomic plane property for the plane source + * position in the connected &drm_framebuffer. + */ struct drm_property *prop_src_w; + /** + * @prop_src_h: Default atomic plane property for the plane source + * position in the connected &drm_framebuffer. + */ struct drm_property *prop_src_h; + /** + * @prop_crtc_x: Default atomic plane property for the plane destination + * position in the &drm_crtc is is being shown on. + */ struct drm_property *prop_crtc_x; + /** + * @prop_crtc_y: Default atomic plane property for the plane destination + * position in the &drm_crtc is is being shown on. + */ struct drm_property *prop_crtc_y; + /** + * @prop_crtc_w: Default atomic plane property for the plane destination + * position in the &drm_crtc is is being shown on. + */ struct drm_property *prop_crtc_w; + /** + * @prop_crtc_h: Default atomic plane property for the plane destination + * position in the &drm_crtc is is being shown on. + */ struct drm_property *prop_crtc_h; + /** + * @prop_fb_id: Default atomic plane property to specify the + * &drm_framebuffer. + */ struct drm_property *prop_fb_id; + /** + * @prop_crtc_id: Default atomic plane property to specify the + * &drm_crtc. + */ struct drm_property *prop_crtc_id; + /** + * @prop_active: Default atomic CRTC property to control the active + * state, which is the simplified implementation for DPMS in atomic + * drivers. + */ struct drm_property *prop_active; + /** + * @prop_mode_id: Default atomic CRTC property to set the mode for a + * CRTC. A 0 mode implies that the CRTC is entirely disabled - all + * connectors must be of and active must be set to disabled, too. + */ struct drm_property *prop_mode_id; - /* DVI-I properties */ + /** + * @dvi_i_subconnector_property: Optional DVI-I property to + * differentiate between analog or digital mode. + */ struct drm_property *dvi_i_subconnector_property; + /** + * @dvi_i_select_subconnector_property: Optional DVI-I property to + * select between analog or digital mode. + */ struct drm_property *dvi_i_select_subconnector_property; - /* TV properties */ + /** + * @tv_subconnector_property: Optional TV property to differentiate + * between different TV connector types. + */ struct drm_property *tv_subconnector_property; + /** + * @tv_select_subconnector_property: Optional TV property to select + * between different TV connector types. + */ struct drm_property *tv_select_subconnector_property; + /** + * @tv_mode_property: Optional TV property to select + * the output TV mode. + */ struct drm_property *tv_mode_property; + /** + * @tv_left_margin_property: Optional TV property to set the left + * margin. + */ struct drm_property *tv_left_margin_property; + /** + * @tv_right_margin_property: Optional TV property to set the right + * margin. + */ struct drm_property *tv_right_margin_property; + /** + * @tv_top_margin_property: Optional TV property to set the right + * margin. + */ struct drm_property *tv_top_margin_property; + /** + * @tv_bottom_margin_property: Optional TV property to set the right + * margin. + */ struct drm_property *tv_bottom_margin_property; + /** + * @tv_brightness_property: Optional TV property to set the + * brightness. + */ struct drm_property *tv_brightness_property; + /** + * @tv_contrast_property: Optional TV property to set the + * contrast. + */ struct drm_property *tv_contrast_property; + /** + * @tv_flicker_reduction_property: Optional TV property to control the + * flicker reduction mode. + */ struct drm_property *tv_flicker_reduction_property; + /** + * @tv_overscan_property: Optional TV property to control the overscan + * setting. + */ struct drm_property *tv_overscan_property; + /** + * @tv_saturation_property: Optional TV property to set the + * saturation. + */ struct drm_property *tv_saturation_property; + /** + * @tv_hue_property: Optional TV property to set the hue. + */ struct drm_property *tv_hue_property; - /* Optional properties */ + /** + * @scaling_mode_property: Optional connector property to control the + * upscaling, mostly used for built-in panels. + */ struct drm_property *scaling_mode_property; + /** + * @aspect_ratio_property: Optional connector property to control the + * HDMI infoframe aspect ratio setting. + */ struct drm_property *aspect_ratio_property; + /** + * @dirty_info_property: Optional connector property to give userspace a + * hint that the DIRTY_FB ioctl should be used. + */ struct drm_property *dirty_info_property; - /* Optional color correction properties */ + /** + * @degamma_lut_property: Optional CRTC property to set the LUT used to + * convert the framebuffer's colors to linear gamma. + */ struct drm_property *degamma_lut_property; + /** + * @degamma_lut_size_property: Optional CRTC property for the size of + * the degamma LUT as supported by the driver (read-only). + */ struct drm_property *degamma_lut_size_property; + /** + * @ctm_property: Optional CRTC property to set the + * matrix used to convert colors after the lookup in the + * degamma LUT. + */ struct drm_property *ctm_property; + /** + * @gamma_lut_property: Optional CRTC property to set the LUT used to + * convert the colors, after the CTM matrix, to the gamma space of the + * connected screen. + */ struct drm_property *gamma_lut_property; + /** + * @gamma_lut_size_property: Optional CRTC property for the size of the + * gamma LUT as supported by the driver (read-only). + */ struct drm_property *gamma_lut_size_property; - /* properties for virtual machine layout */ + /** + * @suggested_x_property: Optional connector property with a hint for + * the position of the output on the host's screen. + */ struct drm_property *suggested_x_property; + /** + * @suggested_y_property: Optional connector property with a hint for + * the position of the output on the host's screen. + */ struct drm_property *suggested_y_property; /* dumb ioctl parameters */ uint32_t preferred_depth, prefer_shadow; - /* whether async page flip is supported or not */ + /** + * @async_page_flip: Does this device support async flips on the primary + * plane? + */ bool async_page_flip; /** -- cgit v1.2.3 From 34a67dd7f33f3476bc9978c3d353703d3821f6c2 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Fri, 15 Jul 2016 21:48:01 +0200 Subject: drm: Extract&Document drm_irq.h The drm_irq docs want one function from drmP.h, but that one is a serious mess. Extract it, and while at it improve the docs a bit. There's a bit a header loop issue since core data structures like drm_device and drm_driver aren't in their own headers yet, which means the drm_irq.h include in drmP.h needs to be in just the right spot :( Also noticed that drm_vblank_crtc->last_wait is entirely unused, remove it. v2: git add drm_irq.h ... Acked-by: Chris Wilson Signed-off-by: Daniel Vetter --- include/drm/drmP.h | 83 +---------------------- include/drm/drm_irq.h | 183 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 186 insertions(+), 80 deletions(-) create mode 100644 include/drm/drm_irq.h (limited to 'include') diff --git a/include/drm/drmP.h b/include/drm/drmP.h index c2fe2cffb809..d3778652e462 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -52,7 +52,6 @@ #include #include #include -#include #include #include #include @@ -87,6 +86,7 @@ struct drm_device_dma; struct drm_dma_handle; struct drm_gem_object; struct drm_master; +struct drm_vblank_crtc; struct device_node; struct videomode; @@ -684,35 +684,6 @@ struct drm_minor { struct mutex debugfs_lock; /* Protects debugfs_list. */ }; - -struct drm_pending_vblank_event { - struct drm_pending_event base; - unsigned int pipe; - struct drm_event_vblank event; -}; - -struct drm_vblank_crtc { - struct drm_device *dev; /* pointer to the drm_device */ - wait_queue_head_t queue; /**< VBLANK wait queue */ - struct timer_list disable_timer; /* delayed disable timer */ - - seqlock_t seqlock; /* protects vblank count and time */ - - u32 count; /* vblank counter */ - struct timeval time; /* vblank timestamp */ - - atomic_t refcount; /* number of users of vblank interruptsper crtc */ - u32 last; /* protected by dev->vbl_lock, used */ - /* for wraparound handling */ - u32 last_wait; /* Last vblank seqno waited per CRTC */ - unsigned int inmodeset; /* Display driver is setting mode */ - unsigned int pipe; /* crtc index */ - int framedur_ns; /* frame/field duration in ns */ - int linedur_ns; /* line duration in ns */ - bool enabled; /* so we don't call enable more than - once per disable */ -}; - /** * DRM device structure. This structure represent a complete card that * may contain multiple heads. @@ -847,6 +818,8 @@ struct drm_device { int switch_power_state; }; +#include + #define DRM_SWITCH_POWER_ON 0 #define DRM_SWITCH_POWER_OFF 1 #define DRM_SWITCH_POWER_CHANGING 2 @@ -933,56 +906,6 @@ void drm_clflush_virt_range(void *addr, unsigned long length); * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. */ - /* IRQ support (drm_irq.h) */ -extern int drm_irq_install(struct drm_device *dev, int irq); -extern int drm_irq_uninstall(struct drm_device *dev); - -extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs); -extern int drm_wait_vblank(struct drm_device *dev, void *data, - struct drm_file *filp); -extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe); -extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc); -extern u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc, - struct timeval *vblanktime); -extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc, - struct drm_pending_vblank_event *e); -extern void drm_crtc_arm_vblank_event(struct drm_crtc *crtc, - struct drm_pending_vblank_event *e); -extern bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe); -extern bool drm_crtc_handle_vblank(struct drm_crtc *crtc); -extern int drm_crtc_vblank_get(struct drm_crtc *crtc); -extern void drm_crtc_vblank_put(struct drm_crtc *crtc); -extern void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe); -extern void drm_crtc_wait_one_vblank(struct drm_crtc *crtc); -extern void drm_vblank_off(struct drm_device *dev, unsigned int pipe); -extern void drm_vblank_on(struct drm_device *dev, unsigned int pipe); -extern void drm_crtc_vblank_off(struct drm_crtc *crtc); -extern void drm_crtc_vblank_reset(struct drm_crtc *crtc); -extern void drm_crtc_vblank_on(struct drm_crtc *crtc); -extern void drm_vblank_cleanup(struct drm_device *dev); -extern u32 drm_accurate_vblank_count(struct drm_crtc *crtc); -extern u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe); - -extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, - unsigned int pipe, int *max_error, - struct timeval *vblank_time, - unsigned flags, - const struct drm_display_mode *mode); -extern void drm_calc_timestamping_constants(struct drm_crtc *crtc, - const struct drm_display_mode *mode); - -/** - * drm_crtc_vblank_waitqueue - get vblank waitqueue for the CRTC - * @crtc: which CRTC's vblank waitqueue to retrieve - * - * This function returns a pointer to the vblank waitqueue for the CRTC. - * Drivers can use this to implement vblank waits using wait_event() & co. - */ -static inline wait_queue_head_t *drm_crtc_vblank_waitqueue(struct drm_crtc *crtc) -{ - return &crtc->dev->vblank[drm_crtc_index(crtc)].queue; -} - /* Modesetting support */ extern void drm_vblank_pre_modeset(struct drm_device *dev, unsigned int pipe); extern void drm_vblank_post_modeset(struct drm_device *dev, unsigned int pipe); diff --git a/include/drm/drm_irq.h b/include/drm/drm_irq.h new file mode 100644 index 000000000000..2401b14d301f --- /dev/null +++ b/include/drm/drm_irq.h @@ -0,0 +1,183 @@ +/* + * Copyright 2016 Intel Corp. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _DRM_IRQ_H_ +#define _DRM_IRQ_H_ + +#include + +/** + * struct drm_pending_vblank_event - pending vblank event tracking + */ +struct drm_pending_vblank_event { + /** + * @base: Base structure for tracking pending DRM events. + */ + struct drm_pending_event base; + /** + * @pipe: drm_crtc_index() of the &drm_crtc this event is for. + */ + unsigned int pipe; + /** + * @event: Actual event which will be sent to userspace. + */ + struct drm_event_vblank event; +}; + +/** + * struct drm_vblank_crtc - vblank tracking for a CRTC + * + * This structure tracks the vblank state for one CRTC. + * + * Note that for historical reasons - the vblank handling code is still shared + * with legacy/non-kms drivers - this is a free-standing structure not directly + * connected to struct &drm_crtc. But all public interface functions are taking + * a struct &drm_crtc to hide this implementation detail. + */ +struct drm_vblank_crtc { + /** + * @dev: Pointer to the &drm_device. + */ + struct drm_device *dev; + /** + * @queue: Wait queue for vblank waiters. + */ + wait_queue_head_t queue; /**< VBLANK wait queue */ + /** + * @disable_timer: Disable timer for the delayed vblank disabling + * hysteresis logic. Vblank disabling is controlled through the + * drm_vblank_offdelay module option and the setting of the + * max_vblank_count value in the &drm_device structure. + */ + struct timer_list disable_timer; + + /** + * @seqlock: Protect vblank count and time. + */ + seqlock_t seqlock; /* protects vblank count and time */ + + /** + * @count: Current software vblank counter. + */ + u32 count; + /** + * @time: Vblank timestamp corresponding to @count. + */ + struct timeval time; + + /** + * @refcount: Number of users/waiters of the vblank interrupt. Only when + * this refcount reaches 0 can the hardware interrupt be disabled using + * @disable_timer. + */ + atomic_t refcount; /* number of users of vblank interruptsper crtc */ + /** + * @last: Protected by dev->vbl_lock, used for wraparound handling. + */ + u32 last; + /** + * @inmodeset: Tracks whether the vblank is disabled due to a modeset. + * For legacy driver bit 2 additionally tracks whether an additional + * temporary vblank reference has been acquired to paper over the + * hardware counter resetting/jumping. KMS drivers should instead just + * call drm_crtc_vblank_off() and drm_crtc_vblank_on(), which explicitly + * save and restore the vblank count. + */ + unsigned int inmodeset; /* Display driver is setting mode */ + /** + * @pipe: drm_crtc_index() of the &drm_crtc corresponding to this + * structure. + */ + unsigned int pipe; + /** + * @framedur_ns: Frame/Field duration in ns, used by + * drm_calc_vbltimestamp_from_scanoutpos() and computed by + * drm_calc_timestamping_constants(). + */ + int framedur_ns; + /** + * @linedur_ns: Line duration in ns, used by + * drm_calc_vbltimestamp_from_scanoutpos() and computed by + * drm_calc_timestamping_constants(). + */ + int linedur_ns; + /** + * @enabled: Tracks the enabling state of the corresponding &drm_crtc to + * avoid double-disabling and hence corrupting saved state. Needed by + * drivers not using atomic KMS, since those might go through their CRTC + * disabling functions multiple times. + */ + bool enabled; +}; + +extern int drm_irq_install(struct drm_device *dev, int irq); +extern int drm_irq_uninstall(struct drm_device *dev); + +extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs); +extern int drm_wait_vblank(struct drm_device *dev, void *data, + struct drm_file *filp); +extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe); +extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc); +extern u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc, + struct timeval *vblanktime); +extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc, + struct drm_pending_vblank_event *e); +extern void drm_crtc_arm_vblank_event(struct drm_crtc *crtc, + struct drm_pending_vblank_event *e); +extern bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe); +extern bool drm_crtc_handle_vblank(struct drm_crtc *crtc); +extern int drm_crtc_vblank_get(struct drm_crtc *crtc); +extern void drm_crtc_vblank_put(struct drm_crtc *crtc); +extern void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe); +extern void drm_crtc_wait_one_vblank(struct drm_crtc *crtc); +extern void drm_vblank_off(struct drm_device *dev, unsigned int pipe); +extern void drm_vblank_on(struct drm_device *dev, unsigned int pipe); +extern void drm_crtc_vblank_off(struct drm_crtc *crtc); +extern void drm_crtc_vblank_reset(struct drm_crtc *crtc); +extern void drm_crtc_vblank_on(struct drm_crtc *crtc); +extern void drm_vblank_cleanup(struct drm_device *dev); +extern u32 drm_accurate_vblank_count(struct drm_crtc *crtc); +extern u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe); + +extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, + unsigned int pipe, int *max_error, + struct timeval *vblank_time, + unsigned flags, + const struct drm_display_mode *mode); +extern void drm_calc_timestamping_constants(struct drm_crtc *crtc, + const struct drm_display_mode *mode); + +/** + * drm_crtc_vblank_waitqueue - get vblank waitqueue for the CRTC + * @crtc: which CRTC's vblank waitqueue to retrieve + * + * This function returns a pointer to the vblank waitqueue for the CRTC. + * Drivers can use this to implement vblank waits using wait_event() and related + * functions. + */ +static inline wait_queue_head_t *drm_crtc_vblank_waitqueue(struct drm_crtc *crtc) +{ + return &crtc->dev->vblank[drm_crtc_index(crtc)].queue; +} + +#endif -- cgit v1.2.3 From 212ae8918ce69b4f6ec980b21f27eeadf15197d8 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Fri, 15 Jul 2016 21:48:02 +0200 Subject: drm/doc: Fix missing kerneldoc for drm_dp_helper.c Never added when the DP validation code was added. Acked-by: Chris Wilson Signed-off-by: Daniel Vetter Link: http://patchwork.freedesktop.org/patch/msgid/1468612088-9721-5-git-send-email-daniel.vetter@ffwll.ch --- include/drm/drm_dp_helper.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h index 4d85cf2874af..72dee1213268 100644 --- a/include/drm/drm_dp_helper.h +++ b/include/drm/drm_dp_helper.h @@ -747,7 +747,14 @@ struct drm_dp_aux { struct mutex hw_mutex; ssize_t (*transfer)(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg); - unsigned i2c_nack_count, i2c_defer_count; + /** + * @i2c_nack_count: Counts I2C NACKs, used for DP validation. + */ + unsigned i2c_nack_count; + /** + * @i2c_defer_count: Counts I2C DEFERs, used for DP validation. + */ + unsigned i2c_defer_count; }; ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset, -- cgit v1.2.3 From cb021a3eb6e9870d2f3539e37d8b6de4c9d919f6 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Fri, 15 Jul 2016 21:48:03 +0200 Subject: drm/dp-mst: Remove tx_down_in_progress Just replicates whether the list is empty or not. Nuke code to avoid writing docs for it! Cc: Dave Airlie Reviewed-by: Chris Wilson Signed-off-by: Daniel Vetter Link: http://patchwork.freedesktop.org/patch/msgid/1468612088-9721-6-git-send-email-daniel.vetter@ffwll.ch --- include/drm/drm_dp_mst_helper.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h index fdb47051d549..c49bbfaf3cbb 100644 --- a/include/drm/drm_dp_mst_helper.h +++ b/include/drm/drm_dp_mst_helper.h @@ -446,7 +446,6 @@ struct drm_dp_mst_topology_mgr { the mstb tx_slots and txmsg->state once they are queued */ struct mutex qlock; struct list_head tx_msg_downq; - bool tx_down_in_progress; /* payload info + lock for it */ struct mutex payload_lock; -- cgit v1.2.3 From 132d49d728f3af67378ebb01b98cd513f4a2ab1b Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Fri, 15 Jul 2016 21:48:04 +0200 Subject: drm/dp-mst: Missing kernel doc Cc: Dave Airlie Acked-by: Chris Wilson Signed-off-by: Daniel Vetter Link: http://patchwork.freedesktop.org/patch/msgid/1468612088-9721-7-git-send-email-daniel.vetter@ffwll.ch --- include/drm/drm_dp_mst_helper.h | 140 +++++++++++++++++++++++++++++++++------- 1 file changed, 116 insertions(+), 24 deletions(-) (limited to 'include') diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h index c49bbfaf3cbb..003207670597 100644 --- a/include/drm/drm_dp_mst_helper.h +++ b/include/drm/drm_dp_mst_helper.h @@ -87,7 +87,15 @@ struct drm_dp_mst_port { struct drm_connector *connector; struct drm_dp_mst_topology_mgr *mgr; - struct edid *cached_edid; /* for DP logical ports - make tiling work */ + /** + * @cached_edid: for DP logical ports - make tiling work by ensuring + * that the EDID for all connectors is read immediately. + */ + struct edid *cached_edid; + /** + * @has_audio: Tracks whether the sink connector to this port is + * audio-capable. + */ bool has_audio; }; @@ -397,70 +405,154 @@ struct drm_dp_payload { /** * struct drm_dp_mst_topology_mgr - DisplayPort MST manager - * @dev: device pointer for adding i2c devices etc. - * @cbs: callbacks for connector addition and destruction. - * @max_dpcd_transaction_bytes - maximum number of bytes to read/write in one go. - * @aux: aux channel for the DP connector. - * @max_payloads: maximum number of payloads the GPU can generate. - * @conn_base_id: DRM connector ID this mgr is connected to. - * @down_rep_recv: msg receiver state for down replies. - * @up_req_recv: msg receiver state for up requests. - * @lock: protects mst state, primary, dpcd. - * @mst_state: if this manager is enabled for an MST capable port. - * @mst_primary: pointer to the primary branch device. - * @dpcd: cache of DPCD for primary port. - * @pbn_div: PBN to slots divisor. * * This struct represents the toplevel displayport MST topology manager. * There should be one instance of this for every MST capable DP connector * on the GPU. */ struct drm_dp_mst_topology_mgr { - + /** + * @dev: device pointer for adding i2c devices etc. + */ struct device *dev; + /** + * @cbs: callbacks for connector addition and destruction. + */ const struct drm_dp_mst_topology_cbs *cbs; + /** + * @max_dpcd_transaction_bytes: maximum number of bytes to read/write + * in one go. + */ int max_dpcd_transaction_bytes; - struct drm_dp_aux *aux; /* auxch for this topology mgr to use */ + /** + * @aux: AUX channel for the DP MST connector this topolgy mgr is + * controlling. + */ + struct drm_dp_aux *aux; + /** + * @max_payloads: maximum number of payloads the GPU can generate. + */ int max_payloads; + /** + * @conn_base_id: DRM connector ID this mgr is connected to. Only used + * to build the MST connector path value. + */ int conn_base_id; - /* only ever accessed from the workqueue - which should be serialised */ + /** + * @down_rep_recv: Message receiver state for down replies. This and + * @up_req_recv are only ever access from the work item, which is + * serialised. + */ struct drm_dp_sideband_msg_rx down_rep_recv; + /** + * @up_req_recv: Message receiver state for up requests. This and + * @down_rep_recv are only ever access from the work item, which is + * serialised. + */ struct drm_dp_sideband_msg_rx up_req_recv; - /* pointer to info about the initial MST device */ - struct mutex lock; /* protects mst_state + primary + dpcd */ + /** + * @lock: protects mst state, primary, dpcd. + */ + struct mutex lock; + /** + * @mst_state: If this manager is enabled for an MST capable port. False + * if no MST sink/branch devices is connected. + */ bool mst_state; + /** + * @mst_primary: Pointer to the primary/first branch device. + */ struct drm_dp_mst_branch *mst_primary; + /** + * @dpcd: Cache of DPCD for primary port. + */ u8 dpcd[DP_RECEIVER_CAP_SIZE]; + /** + * @sink_count: Sink count from DEVICE_SERVICE_IRQ_VECTOR_ESI0. + */ u8 sink_count; + /** + * @pbn_div: PBN to slots divisor. + */ int pbn_div; + /** + * @total_slots: Total slots that can be allocated. + */ int total_slots; + /** + * @avail_slots: Still available slots that can be allocated. + */ int avail_slots; + /** + * @total_pbn: Total PBN count. + */ int total_pbn; - /* messages to be transmitted */ - /* qlock protects the upq/downq and in_progress, - the mstb tx_slots and txmsg->state once they are queued */ + /** + * @qlock: protects @tx_msg_downq, the tx_slots in struct + * &drm_dp_mst_branch and txmsg->state once they are queued + */ struct mutex qlock; + /** + * @tx_msg_downq: List of pending down replies. + */ struct list_head tx_msg_downq; - /* payload info + lock for it */ + /** + * @payload_lock: Protect payload information. + */ struct mutex payload_lock; + /** + * @proposed_vcpis: Array of pointers for the new VCPI allocation. The + * VCPI structure itself is embedded into the corresponding + * &drm_dp_mst_port structure. + */ struct drm_dp_vcpi **proposed_vcpis; + /** + * @payloads: Array of payloads. + */ struct drm_dp_payload *payloads; + /** + * @payload_mask: Elements of @payloads actually in use. Since + * reallocation of active outputs isn't possible gaps can be created by + * disabling outputs out of order compared to how they've been enabled. + */ unsigned long payload_mask; + /** + * @vcpi_mask: Similar to @payload_mask, but for @proposed_vcpis. + */ unsigned long vcpi_mask; + /** + * @tx_waitq: Wait to queue stall for the tx worker. + */ wait_queue_head_t tx_waitq; + /** + * @work: Probe work. + */ struct work_struct work; - + /** + * @tx_work: Sideband transmit worker. This can nest within the main + * @work worker for each transaction @work launches. + */ struct work_struct tx_work; + /** + * @destroy_connector_list: List of to be destroyed connectors. + */ struct list_head destroy_connector_list; + /** + * @destroy_connector_lock: Protects @connector_list. + */ struct mutex destroy_connector_lock; + /** + * @destroy_connector_work: Work item to destroy connectors. Needed to + * avoid locking inversion. + */ struct work_struct destroy_connector_work; }; -- cgit v1.2.3 From 6942559980c036b240c60b135a4bf23bf3252b48 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Tue, 19 Jul 2016 18:25:01 +0200 Subject: drm: drm_connector->s/connector_id/index/ for consistency connector_id in the uapi actually means drm_connector->base.id, which is something entirely different. And ->index is also consistent with plane/encoder/CRTCS and the various drm_*_index() functions. While at it also improve/align the kerneldoc comment. v2: Mention where those ids are from ... v3: Add -ing to supporting and try to not break the world. Cc: Chris Wilson Cc: Maarten Lankhorst Acked-by: Chris Wilson Acked-by: Maarten Lankhorst Signed-off-by: Daniel Vetter Link: http://patchwork.freedesktop.org/patch/msgid/1468945501-23166-1-git-send-email-daniel.vetter@ffwll.ch --- include/drm/drm_crtc.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index f8ba5aab5d28..3edeaf88ebc0 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1246,7 +1246,6 @@ struct drm_encoder { * @head: list management * @base: base KMS object * @name: human readable name, can be overwritten by the driver - * @connector_id: compacted connector id useful indexing arrays * @connector_type: one of the %DRM_MODE_CONNECTOR_ types from drm_mode.h * @connector_type_id: index into connector type enum * @interlace_allowed: can this connector handle interlaced modes? @@ -1303,7 +1302,15 @@ struct drm_connector { struct drm_mode_object base; char *name; - int connector_id; + + /** + * @index: Compacted connector index, which matches the position inside + * the mode_config.list for drivers not supporting hot-add/removing. Can + * be used as an array index. It is invariant over the lifetime of the + * connector. + */ + unsigned index; + int connector_type; int connector_type_id; bool interlace_allowed; @@ -2764,7 +2771,7 @@ void drm_connector_unregister(struct drm_connector *connector); extern void drm_connector_cleanup(struct drm_connector *connector); static inline unsigned drm_connector_index(struct drm_connector *connector) { - return connector->connector_id; + return connector->index; } extern __printf(5, 6) -- cgit v1.2.3