FBC (+stolen) locking, v5
Subsystems (2)
cover FBC (+stolen) locking, v5
From: Paulo Zanoni <[email protected]>
The big difference in this series is the fact that stolen_lock got much simpler. I was previously afraid of doing the CFB release and realloc operations in a non-atomic way, but I redebugged things and realized that, after we fixed the CFB size checks, we're not trying to free+allocate the CFB with FBC enabled, so we can make stolen_lock become much simpler.
Thanks Chris for the suggestions and reviews!
Paulo Zanoni (8):
drm/i915: add simple wrappers for stolen node insertion/removal drm/i915: move FBC code out of i915_gem_stolen.c drm/i915: add dev_priv->mm.stolen_lock
drm/i915: add the FBC mutex
drm/i915: intel_frontbuffer_flip_prepare() doesn't need struct_mutex drm/i915: intel_unregister_dsm_handler() doesn't need struct_mutex drm/i915: FBC doesn't need struct_mutex anymore
drm/i915: protect FBC functions with HAS_FBC checks
drivers/gpu/drm/i915/i915_debugfs.c | 8 +- drivers/gpu/drm/i915/i915_dma.c | 1 + drivers/gpu/drm/i915/i915_drv.h | 14 +- drivers/gpu/drm/i915/i915_gem_stolen.c | 171 +++++------------------ drivers/gpu/drm/i915/intel_display.c | 20 +-- drivers/gpu/drm/i915/intel_drv.h | 2 + drivers/gpu/drm/i915/intel_fbc.c | 241 ++++++++++++++++++++++++++++++--- 7 files changed, 280 insertions(+), 177 deletions(-)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/8 drm/i915: add simple wrappers for stolen node insertion/removal
From: Paulo Zanoni <[email protected]>
We want to move the FBC code out of i915_gem_stolen.c, but that code directly adds/removes stolen memory nodes. Let's create this abstraction, so i915_gme_stolen.c is still in control of all the stolen memory handling. The abstraction will also allow us to add locking assertions later.
v2:
- Add dev_priv as remove_node() argument since we'll need it later
(Chris).
--- drivers/gpu/drm/i915/i915_drv.h | 5 ++++ drivers/gpu/drm/i915/i915_gem_stolen.c | 48 ++++++++++++++++++++++------------ 2 files changed, 37 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +5 -0
@@ -3109,6 +3109,11 @@ static inline void i915_gem_chipset_flush(struct drm_device *dev) }/* i915_gem_stolen.c */ +int i915_gem_stolen_insert_node (struct drm_i915_private *dev_priv, +struct drm_mm_node *node,u64 size, +unsigned alignment); +void i915_gem_stolen_remove_node (struct drm_i915_private *dev_priv, +struct drm_mm_node *node);int i915_gem_init_stolen (struct drm_device *dev);int i915_gem_stolen_setup_compression (struct drm_device *dev,int size,int fb_cpp);void i915_gem_stolen_cleanup_compression (struct drm_device *dev);
drivers/gpu/drm/i915/i915_gem_stolen.c +32 -16
117 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/8 drm/i915: move FBC code out of i915_gem_stolen.c
In reply to Paulo ZanoniFrom: Paulo Zanoni <[email protected]>
With the abstractions created by the last patch, we can move this code and the only thing inside intel_fbc.c that knows about dev_priv->mm is the code that reads stolen_base.
We also had to move a call to i915_gem_stolen_cleanup_compression()
- now called intel_fbc_cleanup_cfb() - outside i915_gem_stolen.c.
v2:
- Rebase after the remove_node() changes on the previous patch.
--- drivers/gpu/drm/i915/i915_dma.c | 1 + drivers/gpu/drm/i915/i915_drv.h | 2 - drivers/gpu/drm/i915/i915_gem_stolen.c | 127 -------------------------------- drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_fbc.c | 129 ++++++++++++++++++++++++++++++++- 5 files changed, 128 insertions(+), 132 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +1 -0
@@ -1120,6 +1120,7 @@ int i915_driver_unload(struct drm_device *dev)i915_gem_cleanup_ringbuffer (dev);i915_gem_context_fini (dev);mutex_unlock (&dev->struct_mutex); +intel_fbc_cleanup_cfb (dev);i915_gem_cleanup_stolen (dev);intel_csr_ucode_fini (dev);
drivers/gpu/drm/i915/i915_drv.h +0 -2
@@ -3115,8 +3115,6 @@ int i915_gem_stolen_insert_node(struct drm_i915_private *dev_priv,void i915_gem_stolen_remove_node (struct drm_i915_private *dev_priv,struct drm_mm_node *node);int i915_gem_init_stolen (struct drm_device *dev); -int i915_gem_stolen_setup_compression (struct drm_device *dev,int size,int fb_cpp); -void i915_gem_stolen_cleanup_compression (struct drm_device *dev);void i915_gem_cleanup_stolen (struct drm_device *dev);struct drm_i915_gem_object *i915_gem_object_create_stolen (struct drm_device *dev,u32 size);
drivers/gpu/drm/i915/i915_gem_stolen.c +0 -127
139 lines not on this page · raw message
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -1258,6 +1258,7 @@ void intel_fbc_invalidate(struct drm_i915_private *dev_priv,void intel_fbc_flush (struct drm_i915_private *dev_priv,unsigned int frontbuffer_bits);const char *intel_no_fbc_reason_str (enum no_fbc_reason reason); +void intel_fbc_cleanup_cfb (struct drm_device *dev);/* intel_hdmi.c */ void intel_hdmi_init (struct drm_device *dev,int hdmi_reg,enum port port);
drivers/gpu/drm/i915/intel_fbc.c +126 -3
147 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/8 drm/i915: add dev_priv->mm.stolen_lock
In reply to Paulo ZanoniFrom: Paulo Zanoni <[email protected]>
Which should protect dev_priv->mm.stolen usage. This will allow us to simplify the relationship between stolen memory, FBC and struct_mutex.
v2:
- Rebase after the stolen_remove_node() dev_priv patch move.
- I realized that after we fixed a few things related to the FBC CFB size checks, we're not reallocating the CFB anymore with FBC enabled, so we can just move all the locking to i915_gem_stolen.c and stop worrying about freezing all the stolen alocations while freeing/rellocating the CFB. This allows us to fix the "Too coarse" observation from Chris.
--- drivers/gpu/drm/i915/i915_drv.h | 4 ++++ drivers/gpu/drm/i915/i915_gem_stolen.c | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +4 -0
@@ -1245,6 +1245,10 @@ struct intel_l3_parity {struct i915_gem_mm {/** Memory allocator for GTT stolen memory */ struct drm_mm stolen; +/** Protects the usage of the GTT stolen memory allocator. This is +* always the inner lock when overlapping with struct_mutex. */ +struct mutex stolen_lock; +/** List of all objects in gtt_space. Used to restore gtt * mappings on resume */ struct list_head bound_list;
drivers/gpu/drm/i915/i915_gem_stolen.c +14 -2
@@ -46,17 +46,25 @@ int i915_gem_stolen_insert_node(struct drm_i915_private *dev_priv, struct drm_mm_node *node, u64 size, unsigned alignment) { + int ret; +if (!drm_mm_initialized (&dev_priv->mm.stolen))return -ENODEV ; -return drm_mm_insert_node (&dev_priv->mm.stolen, node, size, alignment, -DRM_MM_SEARCH_DEFAULT ); +mutex_lock (&dev_priv->mm.stolen_lock); + ret =drm_mm_insert_node (&dev_priv->mm.stolen, node, size, alignment, +DRM_MM_SEARCH_DEFAULT ); +mutex_unlock (&dev_priv->mm.stolen_lock); + +return ret; }void i915_gem_stolen_remove_node (struct drm_i915_private *dev_priv,struct drm_mm_node *node) { +mutex_lock (&dev_priv->mm.stolen_lock);drm_mm_remove_node (node); +mutex_unlock (&dev_priv->mm.stolen_lock); }static unsigned long i915_stolen_to_physical (struct drm_device *dev)
@@ -184,6 +192,8 @@ int i915_gem_init_stolen(struct drm_device *dev)u32 tmp;int bios_reserved =0 ; +mutex_init (&dev_priv->mm.stolen_lock); +#ifdef CONFIG_INTEL_IOMMU if (intel_iommu_gfx_mapped &&INTEL_INFO (dev)->gen <8 ) {DRM_INFO ("DMAR active, disabling use of stolen memory\n" );
@@ -384,7 +394,9 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, stolen->start = stolen_offset; stolen->size = size; +mutex_lock (&dev_priv->mm.stolen_lock); ret =drm_mm_reserve_node (&dev_priv->mm.stolen, stolen); +mutex_unlock (&dev_priv->mm.stolen_lock);if (ret) {DRM_DEBUG_KMS ("failed to allocate stolen space\n" );kfree (stolen);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/8 drm/i915: add the FBC mutex
In reply to Paulo ZanoniFrom: Paulo Zanoni <[email protected]>
Make sure we're not going to have weird races in really weird cases where a lot of different CRTCs are doing rendering and modesets at the same time.
With this change and the stolen_lock from the previous patch, we can start removing the struct_mutex locking we have around FBC in the next patches.
v2:
- Rebase (6 months later)
- Also lock debugfs and stolen.
v3:
- Don't lock a single value read (Chris).
- Replace lockdep assertions with WARNs (Daniel).
- Improve commit message.
- Don't forget intel_pre_plane_update() locking.
v4:
- Don't remove struct_mutex at intel_pre_plane_update() (Chris).
- Add comment regarding locking dependencies (Chris).
- Rebase after the stolen code rework.
- Rebase again after drm-intel-nightly changes.
v5:
- Rebase after the new stolen_lock patch.
--- drivers/gpu/drm/i915/i915_debugfs.c | 4 ++ drivers/gpu/drm/i915/i915_drv.h | 3 ++ drivers/gpu/drm/i915/intel_display.c | 6 +-- drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_fbc.c | 101 +++++++++++++++++++++++++++++------ 5 files changed, 96 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +4 -0
@@ -1633,6 +1633,7 @@ static int i915_fbc_status(struct seq_file *m, void *unused) }intel_runtime_pm_get (dev_priv); +mutex_lock (&dev_priv->fbc.lock);if (intel_fbc_enabled (dev))seq_puts (m,"FBC enabled\n" );
@@ -1645,6 +1646,7 @@ static int i915_fbc_status(struct seq_file *m, void *unused)yesno (I915_READ (FBC_STATUS2 ) & FBC_COMPRESSION_MASK)); +mutex_unlock (&dev_priv->fbc.lock);intel_runtime_pm_put (dev_priv);return 0 ;
@@ -1675,6 +1677,7 @@ static int i915_fbc_fc_set(void *data, u64 val)return -ENODEV ;drm_modeset_lock_all (dev); +mutex_lock (&dev_priv->fbc.lock); reg =I915_READ (ILK_DPFC_CONTROL ); dev_priv->fbc.false_color = val;
@@ -1683,6 +1686,7 @@ static int i915_fbc_fc_set(void *data, u64 val) (reg | FBC_CTL_FALSE_COLOR) : (reg & ~FBC_CTL_FALSE_COLOR)); +mutex_unlock (&dev_priv->fbc.lock);drm_modeset_unlock_all (dev);return 0 ; }
drivers/gpu/drm/i915/i915_drv.h +3 -0
@@ -899,6 +899,9 @@ enum fb_op_origin { };struct i915_fbc { +/* This is always the inner lock when overlapping with struct_mutex and +* it's the outer lock when overlapping with stolen_lock. */ +struct mutex lock;unsigned long uncompressed_size;unsigned threshold;unsigned int fb_id;
drivers/gpu/drm/i915/intel_display.c +2 -4
@@ -4783,11 +4783,9 @@ static void intel_pre_plane_update(struct intel_crtc *crtc)if (atomic->wait_for_flips)intel_crtc_wait_for_pending_flips (&crtc->base); -if (atomic->disable_fbc && - dev_priv->fbc.crtc == crtc) { +if (atomic->disable_fbc) {mutex_lock (&dev->struct_mutex); -if (dev_priv->fbc.crtc == crtc) -intel_fbc_disable (dev); +intel_fbc_disable_crtc (crtc);mutex_unlock (&dev->struct_mutex); }
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -1252,6 +1252,7 @@ bool intel_fbc_enabled(struct drm_device *dev);void intel_fbc_update (struct drm_device *dev);void intel_fbc_init (struct drm_i915_private *dev_priv);void intel_fbc_disable (struct drm_device *dev); +void intel_fbc_disable_crtc (struct intel_crtc *crtc);void intel_fbc_invalidate (struct drm_i915_private *dev_priv,unsigned int frontbuffer_bits,enum fb_op_origin origin);
drivers/gpu/drm/i915/intel_fbc.c +86 -15
216 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/8 drm/i915: intel_frontbuffer_flip_prepare() doesn't need struct_mutex
In reply to Paulo ZanoniFrom: Paulo Zanoni <[email protected]>
So release the lock earlier.
--- drivers/gpu/drm/i915/intel_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
@@ -11475,9 +11475,9 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, to_intel_plane(primary)->frontbuffer_bit);intel_fbc_disable (dev); +mutex_unlock (&dev->struct_mutex);intel_frontbuffer_flip_prepare (dev,to_intel_plane (primary)->frontbuffer_bit); -mutex_unlock (&dev->struct_mutex);trace_i915_flip_request (intel_crtc->plane, obj);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 6/8 drm/i915: intel_unregister_dsm_handler() doesn't need struct_mutex
In reply to Paulo ZanoniFrom: Paulo Zanoni <[email protected]>
So don't grab the lock before calling the function.
--- drivers/gpu/drm/i915/intel_display.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -3
@@ -15603,12 +15603,10 @@ void intel_modeset_cleanup(struct drm_device *dev)*/ drm_kms_helper_poll_fini (dev); -mutex_lock (&dev->struct_mutex); -intel_unregister_dsm_handler (); +mutex_lock (&dev->struct_mutex);intel_fbc_disable (dev); -mutex_unlock (&dev->struct_mutex);/* flush any delayed tasks or pending work */
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 7/8 drm/i915: FBC doesn't need struct_mutex anymore
In reply to Paulo ZanoniFrom: Paulo Zanoni <[email protected]>
Everything is covered either by fbc.lock or mm.stolen_lock, and intel_fbc.c is already responsible for grabbing the appropriate locks when it needs them.
--- drivers/gpu/drm/i915/i915_debugfs.c | 4 ---- drivers/gpu/drm/i915/intel_display.c | 14 +++----------- drivers/gpu/drm/i915/intel_fbc.c | 2 -- 3 files changed, 3 insertions(+), 17 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +0 -4
@@ -1660,9 +1660,7 @@ static int i915_fbc_fc_get(void *data, u64 *val)if (INTEL_INFO (dev)->gen <7 || !HAS_FBC (dev))return -ENODEV ; -drm_modeset_lock_all (dev); *val = dev_priv->fbc.false_color; -drm_modeset_unlock_all (dev);return 0 ; }
@@ -1676,7 +1674,6 @@ static int i915_fbc_fc_set(void *data, u64 val)if (INTEL_INFO (dev)->gen <7 || !HAS_FBC (dev))return -ENODEV ; -drm_modeset_lock_all (dev);mutex_lock (&dev_priv->fbc.lock); reg =I915_READ (ILK_DPFC_CONTROL );
@@ -1687,7 +1684,6 @@ static int i915_fbc_fc_set(void *data, u64 val) (reg & ~FBC_CTL_FALSE_COLOR));mutex_unlock (&dev_priv->fbc.lock); -drm_modeset_unlock_all (dev);return 0 ; }
drivers/gpu/drm/i915/intel_display.c +3 -11
@@ -4747,11 +4747,8 @@ static void intel_post_plane_update(struct intel_crtc *crtc)if (crtc->atomic.update_wm_post)intel_update_watermarks (&crtc->base); -if (atomic->update_fbc) { -mutex_lock (&dev->struct_mutex); +if (atomic->update_fbc)intel_fbc_update (dev); -mutex_unlock (&dev->struct_mutex); - }if (atomic->post_enable_primary)intel_post_enable_primary (&crtc->base);
@@ -4783,11 +4780,8 @@ static void intel_pre_plane_update(struct intel_crtc *crtc)if (atomic->wait_for_flips)intel_crtc_wait_for_pending_flips (&crtc->base); -if (atomic->disable_fbc) { -mutex_lock (&dev->struct_mutex); +if (atomic->disable_fbc)intel_fbc_disable_crtc (crtc); -mutex_unlock (&dev->struct_mutex); - }if (crtc->atomic.disable_ips)hsw_disable_ips (crtc);
@@ -11473,9 +11467,9 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,i915_gem_track_fb (intel_fb_obj (work->old_fb), obj,to_intel_plane (primary)->frontbuffer_bit); +mutex_unlock (&dev->struct_mutex);intel_fbc_disable (dev); -mutex_unlock (&dev->struct_mutex);intel_frontbuffer_flip_prepare (dev,to_intel_plane (primary)->frontbuffer_bit);
@@ -15605,9 +15599,7 @@ void intel_modeset_cleanup(struct drm_device *dev)intel_unregister_dsm_handler (); -mutex_lock (&dev->struct_mutex);intel_fbc_disable (dev); -mutex_unlock (&dev->struct_mutex);/* flush any delayed tasks or pending work */ flush_scheduled_work ();
drivers/gpu/drm/i915/intel_fbc.c +0 -2
@@ -335,7 +335,6 @@ static void intel_fbc_work_fn(struct work_struct *__work)struct drm_device *dev = work->crtc->dev;struct drm_i915_private *dev_priv = dev->dev_private; -mutex_lock (&dev->struct_mutex);mutex_lock (&dev_priv->fbc.lock);if (work == dev_priv->fbc.fbc_work) {/* Double check that we haven't switched fb without cancelling
@@ -352,7 +351,6 @@ static void intel_fbc_work_fn(struct work_struct *__work) dev_priv->fbc.fbc_work =NULL ; }mutex_unlock (&dev_priv->fbc.lock); -mutex_unlock (&dev->struct_mutex);kfree (work); }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 8/8 drm/i915: protect FBC functions with HAS_FBC checks
In reply to Paulo ZanoniFrom: Paulo Zanoni <[email protected]>
Now all the functions called by other files have the HAS_FBC protection. This allows us to drop the checks for the low level function pointers.
--- drivers/gpu/drm/i915/intel_fbc.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/intel_fbc.c +18 -9
@@ -388,9 +388,6 @@ static void intel_fbc_enable(struct drm_crtc *crtc)WARN_ON (!mutex_is_locked (&dev_priv->fbc.lock)); -if (!dev_priv->display.enable_fbc) -return ; -intel_fbc_cancel_work (dev_priv); work =kzalloc (sizeof (*work),GFP_KERNEL );
@@ -430,9 +427,6 @@ static void __intel_fbc_disable(struct drm_device *dev)intel_fbc_cancel_work (dev_priv); -if (!dev_priv->display.disable_fbc) -return ; - dev_priv->display.disable_fbc (dev); dev_priv->fbc.crtc =NULL ; }
@@ -447,6 +441,9 @@ void intel_fbc_disable(struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +if (!HAS_FBC (dev_priv)) +return ; +mutex_lock (&dev_priv->fbc.lock);__intel_fbc_disable (dev);mutex_unlock (&dev_priv->fbc.lock);
@@ -463,6 +460,9 @@ void intel_fbc_disable_crtc(struct intel_crtc *crtc)struct drm_device *dev = crtc->base.dev;struct drm_i915_private *dev_priv = dev->dev_private; +if (!HAS_FBC (dev_priv)) +return ; +mutex_lock (&dev_priv->fbc.lock);if (dev_priv->fbc.crtc == crtc)__intel_fbc_disable (dev);
@@ -661,6 +661,9 @@ void intel_fbc_cleanup_cfb(struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +if (!HAS_FBC (dev_priv)) +return ; +mutex_lock (&dev_priv->fbc.lock);__intel_fbc_cleanup_cfb (dev);mutex_unlock (&dev_priv->fbc.lock);
@@ -708,9 +711,6 @@ static void __intel_fbc_update(struct drm_device *dev)const struct drm_display_mode *adjusted_mode;unsigned int max_width, max_height; -if (!HAS_FBC (dev)) -return ; -WARN_ON (!mutex_is_locked (&dev_priv->fbc.lock));/* disable framebuffer compression in vGPU */
@@ -857,6 +857,9 @@ void intel_fbc_update(struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +if (!HAS_FBC (dev_priv)) +return ; +mutex_lock (&dev_priv->fbc.lock);__intel_fbc_update (dev);mutex_unlock (&dev_priv->fbc.lock);
@@ -869,6 +872,9 @@ void intel_fbc_invalidate(struct drm_i915_private *dev_priv,struct drm_device *dev = dev_priv->dev;unsigned int fbc_bits; +if (!HAS_FBC (dev_priv)) +return ; +if (origin ==ORIGIN_GTT )return ;
@@ -895,6 +901,9 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv, {struct drm_device *dev = dev_priv->dev; +if (!HAS_FBC (dev_priv)) +return ; +mutex_lock (&dev_priv->fbc.lock);if (!dev_priv->fbc.busy_bits)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 8/8] drm/i915: protect FBC functions with HAS_FBC checks
Quoted 28 lines · Paulo Zanoni
From: Paulo Zanoni <[email protected]>
Now all the functions called by other files have the
HAS_FBCprotection. This allows us to drop the checks for the low level function pointers.Suggested-by Chris Wilson <[email protected]>Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/gpu/drm/i915/intel_fbc.c +0
-3@@ -388,9 +388,6 @@ static void intel_fbc_enable(struct drm_crtc *crtc)WARN_ON (!mutex_is_locked (&dev_priv->fbc.lock)); -if (!dev_priv->display.enable_fbc) -return ; -intel_fbc_cancel_work (dev_priv); work =kzalloc (sizeof (*work),GFP_KERNEL );
drivers/gpu/drm/i915/intel_fbc.c void intel_fbc_cleanup_cfb(struct drm_device *dev) · line 669
Quoted 9 lines
drivers/gpu/drm/i915/intel_fbc.c +3
-0@@ -661,6 +661,9 @@ void intel_fbc_cleanup_cfb(struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +if (!HAS_FBC (dev_priv)) +return ; +mutex_lock (&dev_priv->fbc.lock);__intel_fbc_cleanup_cfb (dev);mutex_unlock (&dev_priv->fbc.lock);
dev_priv->display.enable_fbc is one less pointer dereference than HAS_FBC() and is a better indication of whether we have initialised the display device for FBC (i.e. it also carries information about whether the setup succeeded, maybe some platforms have HAS_FBC but we fail to negotiate etc).
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/8] drm/i915: add dev_priv->mm.stolen_lock
In reply to Paulo ZanoniQuoted 14 lines · Paulo Zanoni
From: Paulo Zanoni <[email protected]>
Which should protect
dev_priv->mm.stolenusage. This will allow us to simplify the relationship between stolen memory, FBC andstruct_mutex.v2:
- Rebase after thestolen_remove_node()dev_privpatch move.
- I realized that after we fixed a few things related to the FBC CFB size checks, we're not reallocating the CFB anymore with FBC enabled, so we can just move all the locking toi915_gem_stolen.cand stop worrying about freezing all the stolen alocations while freeing/rellocating the CFB. This allows us to fix the "Too coarse" observation from Chris.
Quoted 2 lines
Suggested-by Chris Wilson <[email protected]>Signed-off-by Paulo Zanoni <[email protected]>
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/8] drm/i915: add simple wrappers for stolen node insertion/removal
In reply to Paulo ZanoniQuoted 8 lines · Paulo Zanoni
From: Paulo Zanoni <[email protected]>
We want to move the FBC code out of
i915_gem_stolen.c, but that code directly adds/removes stolen memory nodes. Let's create this abstraction, soi915_gme_stolen.cis still in control of all the stolen memory handling. The abstraction will also allow us to add locking assertions later.
Quoted 6 lines
v2:
- Adddev_privasremove_node()argument since we'll need it later(Chris).Requested-by Chris Wilson <[email protected]>Signed-off-by Paulo Zanoni <[email protected]>
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/8] drm/i915: move FBC code out of i915_gem_stolen.c
In reply to Paulo ZanoniQuoted 6 lines · Paulo Zanoni
From: Paulo Zanoni <[email protected]>
With the abstractions created by the last patch, we can move this code and the only thing inside
intel_fbc.cthat knows aboutdev_priv->mmis the code that readsstolen_base.
Quoted 8 lines
We also had to move a call to
i915_gem_stolen_cleanup_compression()
- now calledintel_fbc_cleanup_cfb()- outsidei915_gem_stolen.c.v2:
- Rebase after theremove_node()changes on the previous patch.Requested-by Chris Wilson <[email protected]>Signed-off-by Paulo Zanoni <[email protected]>
No sneaky changes detected,
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Chris Wilson
Reviewed-byRe: [PATCH 8/8] drm/i915: protect FBC functions with HAS_FBC checks
In reply to Chris WilsonQuoted 32 lines · Chris Wilson
Quoted 31 lines · Paulo Zanoni
From: Paulo Zanoni <[email protected]>
Now all the functions called by other files have the
HAS_FBCprotection. This allows us to drop the checks for the low level function pointers.Suggested-by Chris Wilson <[email protected]>Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/gpu/drm/i915/intel_fbc.c +0
-3@@ -388,9 +388,6 @@ static void intel_fbc_enable(struct drm_crtc *crtc)WARN_ON (!mutex_is_locked (&dev_priv->fbc.lock)); -if (!dev_priv->display.enable_fbc) -return ; -intel_fbc_cancel_work (dev_priv); work =kzalloc (sizeof (*work),GFP_KERNEL );@@ -661,6 +661,9 @@ void intel_fbc_cleanup_cfb(struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;
Quoted 12 lines
drivers/gpu/drm/i915/intel_fbc.c void intel_fbc_cleanup_cfb(struct drm_device *dev) · line 669
Quoted 6 lines
drivers/gpu/drm/i915/intel_fbc.c +3
-0+if (!HAS_FBC (dev_priv)) +return ; +mutex_lock (&dev_priv->fbc.lock);__intel_fbc_cleanup_cfb (dev);mutex_unlock (&dev_priv->fbc.lock);
dev_priv->display.enable_fbcis one less pointer dereference thanHAS_FBC()and is a better indication of whether we have initialised the display device for FBC (i.e. it also carries information about whether the setup succeeded, maybe some platforms haveHAS_FBCbut we fail to negotiate etc).
With or without that change (would prefer with!),
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 8/8] drm/i915: protect FBC functions with HAS_FBC checks
In reply to Chris Wilson2015-07-03 12:56 GMT-03:00 Chris Wilson <[email protected]>:
Quoted 32 lines · Paulo Zanoni
Quoted 31 lines
From: Paulo Zanoni <[email protected]>
Now all the functions called by other files have the
HAS_FBCprotection. This allows us to drop the checks for the low level function pointers.Suggested-by Chris Wilson <[email protected]>Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/gpu/drm/i915/intel_fbc.c +0
-3@@ -388,9 +388,6 @@ static void intel_fbc_enable(struct drm_crtc *crtc)WARN_ON (!mutex_is_locked (&dev_priv->fbc.lock)); -if (!dev_priv->display.enable_fbc) -return ; -intel_fbc_cancel_work (dev_priv); work =kzalloc (sizeof (*work),GFP_KERNEL );@@ -661,6 +661,9 @@ void intel_fbc_cleanup_cfb(struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;
Quoted 8 lines
drivers/gpu/drm/i915/intel_fbc.c void intel_fbc_cleanup_cfb(struct drm_device *dev) · line 669
Quoted 6 lines
drivers/gpu/drm/i915/intel_fbc.c +3
-0+if (!HAS_FBC (dev_priv)) +return ; +mutex_lock (&dev_priv->fbc.lock);__intel_fbc_cleanup_cfb (dev);mutex_unlock (&dev_priv->fbc.lock);
dev_priv->display.enable_fbcis one less pointer dereference thanHAS_FBC()
HAS_FBC(dev_priv) is supposed to be dev_priv->info.has_fbc, which has the same number of pointer dereferences than dev_priv->display.enable_fbc. The problem would be if I had used HAS_FBC(dev).
I also took a look at the __I915__ macro and, although I didn't check the assembly, it seems the "if" statement is removed by the compiler since we never compile BUILD_BUG(). If we wanted to be even more sure we could replace the if statement with nested __builtin_choose_expr() expressions (I even tried doing that, but it didn't reduce the size of stripped i915.ko).
Quoted 4 lines
and is a better indication of whether we have initialised the display device for FBC (i.e. it also carries information about whether the setup succeeded, maybe some platforms have
HAS_FBCbut we fail to negotiate etc).
This argument argument is valid - although that case doesn't happen -, but OTOH a check for HAS_FBC makes it very clear to the code reader what is being excluded, while a check for a function pointer makes the reader wonder about those cases which you mentioned, and they don't really exist, so I'm not sure if this is a good thing. So I guess it's a matter of style preference here.
Quoted 4 lines
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
Signature · 5 lines
Paulo Zanoni _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 8/8] drm/i915: protect FBC functions with HAS_FBC checks
Quoted 42 lines · Paulo Zanoni
2015-07-03 12:56 GMT-03:00 Chris Wilson <[email protected]>:
Quoted 32 lines · Paulo Zanoni
Quoted 31 lines
From: Paulo Zanoni <[email protected]>
Now all the functions called by other files have the
HAS_FBCprotection. This allows us to drop the checks for the low level function pointers.Suggested-by Chris Wilson <[email protected]>Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/gpu/drm/i915/intel_fbc.c +0
-3@@ -388,9 +388,6 @@ static void intel_fbc_enable(struct drm_crtc *crtc)WARN_ON (!mutex_is_locked (&dev_priv->fbc.lock)); -if (!dev_priv->display.enable_fbc) -return ; -intel_fbc_cancel_work (dev_priv); work =kzalloc (sizeof (*work),GFP_KERNEL );@@ -661,6 +661,9 @@ void intel_fbc_cleanup_cfb(struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;Quoted 8 lines
drivers/gpu/drm/i915/intel_fbc.c void intel_fbc_cleanup_cfb(struct drm_device *dev) · line 669
Quoted 6 lines
drivers/gpu/drm/i915/intel_fbc.c +3
-0+if (!HAS_FBC (dev_priv)) +return ; +mutex_lock (&dev_priv->fbc.lock);__intel_fbc_cleanup_cfb (dev);mutex_unlock (&dev_priv->fbc.lock);
dev_priv->display.enable_fbcis one less pointer dereference thanHAS_FBC()
Quoted 4 lines
HAS_FBC(dev_priv)is supposed to bedev_priv->info.has_fbc, which has the same number of pointer dereferences thandev_priv->display.enable_fbc. The problem would be if I had usedHAS_FBC(dev).
I had forgotten we did the copy of intel_device_info into drm_i915_private and still lived in the pre-PCH_NOP days.
Quoted 6 lines
I also took a look at the
__I915__macro and, although I didn't check the assembly, it seems the "if" statement is removed by the compiler since we never compileBUILD_BUG(). If we wanted to be even more sure we could replace the if statement with nested__builtin_choose_expr()expressions (I even tried doing that, but it didn't reduce the size of stripped i915.ko).
if (compile_time_constant) is dead-code eliminated into the single branch (without the jmp).
Hmm, the big advantage (not useful here) is __builtin_choose_expr() can be used as an lvalue. Otherwise it doesn't look like it will generate more readable code than the current macro.
Quoted 11 lines
Quoted 4 lines
and is a better indication of whether we have initialised the display device for FBC (i.e. it also carries information about whether the setup succeeded, maybe some platforms have
HAS_FBCbut we fail to negotiate etc).This argument argument is valid - although that case doesn't happen -, but OTOH a check for
HAS_FBCmakes it very clear to the code reader what is being excluded, while a check for a function pointer makes the reader wonder about those cases which you mentioned, and they don't really exist, so I'm not sure if this is a good thing. So I guess it's a matter of style preference here.
It's the style we have been using elsewhere, certainly in new code (hopefully!). Do the general test during init, then later we ask whether the init suceeded before using the feature.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 8/8 drm/i915: protect FBC functions with FBC checks
From: Paulo Zanoni <[email protected]>
Now all the functions called by other files check whether FBC has been initialized. This allows us to drop the checks on the static functions.
v2:
- s/HAS_FBC/dev_priv->display.enable_fbc/ everywhere but the init function (Chris).
--- drivers/gpu/drm/i915/intel_fbc.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
I'm not 100% sure this is what Chris was asking for v2, so please clarify if this is not what we want.
drivers/gpu/drm/i915/intel_fbc.c +18 -9
@@ -388,9 +388,6 @@ static void intel_fbc_enable(struct drm_crtc *crtc)WARN_ON (!mutex_is_locked (&dev_priv->fbc.lock)); -if (!dev_priv->display.enable_fbc) -return ; -intel_fbc_cancel_work (dev_priv); work =kzalloc (sizeof (*work),GFP_KERNEL );
@@ -430,9 +427,6 @@ static void __intel_fbc_disable(struct drm_device *dev)intel_fbc_cancel_work (dev_priv); -if (!dev_priv->display.disable_fbc) -return ; - dev_priv->display.disable_fbc (dev); dev_priv->fbc.crtc =NULL ; }
@@ -447,6 +441,9 @@ void intel_fbc_disable(struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +if (!dev_priv->display.enable_fbc) +return ; +mutex_lock (&dev_priv->fbc.lock);__intel_fbc_disable (dev);mutex_unlock (&dev_priv->fbc.lock);
@@ -463,6 +460,9 @@ void intel_fbc_disable_crtc(struct intel_crtc *crtc)struct drm_device *dev = crtc->base.dev;struct drm_i915_private *dev_priv = dev->dev_private; +if (!dev_priv->display.enable_fbc) +return ; +mutex_lock (&dev_priv->fbc.lock);if (dev_priv->fbc.crtc == crtc)__intel_fbc_disable (dev);
@@ -661,6 +661,9 @@ void intel_fbc_cleanup_cfb(struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +if (!dev_priv->display.enable_fbc) +return ; +mutex_lock (&dev_priv->fbc.lock);__intel_fbc_cleanup_cfb (dev);mutex_unlock (&dev_priv->fbc.lock);
@@ -708,9 +711,6 @@ static void __intel_fbc_update(struct drm_device *dev)const struct drm_display_mode *adjusted_mode;unsigned int max_width, max_height; -if (!HAS_FBC (dev)) -return ; -WARN_ON (!mutex_is_locked (&dev_priv->fbc.lock));/* disable framebuffer compression in vGPU */
@@ -857,6 +857,9 @@ void intel_fbc_update(struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +if (!dev_priv->display.enable_fbc) +return ; +mutex_lock (&dev_priv->fbc.lock);__intel_fbc_update (dev);mutex_unlock (&dev_priv->fbc.lock);
@@ -869,6 +872,9 @@ void intel_fbc_invalidate(struct drm_i915_private *dev_priv,struct drm_device *dev = dev_priv->dev;unsigned int fbc_bits; +if (!dev_priv->display.enable_fbc) +return ; +if (origin ==ORIGIN_GTT )return ;
@@ -895,6 +901,9 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv, {struct drm_device *dev = dev_priv->dev; +if (!dev_priv->display.enable_fbc) +return ; +mutex_lock (&dev_priv->fbc.lock);if (!dev_priv->fbc.busy_bits)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 8/8] drm/i915: protect FBC functions with FBC checks
Quoted 12 lines · Paulo Zanoni
From: Paulo Zanoni <[email protected]>
Now all the functions called by other files check whether FBC has been initialized. This allows us to drop the checks on the static functions.
v2:
- s/HAS_FBC/dev_priv->display.enable_fbc/ everywhere but the init function (Chris).Suggested-by Chris Wilson <[email protected]>Signed-off-by Paulo Zanoni <[email protected]>
Quoted 7 lines
--- drivers/gpu/drm/i915/intel_fbc.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)I'm not 100% sure this is what Chris was asking for v2, so please clarify if this is not what we want.
Does the trick for me,
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 8/8] drm/i915: protect FBC functions with FBC checks
Quoted 18 lines · Chris Wilson
Quoted 17 lines · Paulo Zanoni
From: Paulo Zanoni <[email protected]>
Now all the functions called by other files check whether FBC has been initialized. This allows us to drop the checks on the static functions.
v2:
- s/HAS_FBC/dev_priv->display.enable_fbc/ everywhere but the init function (Chris).Suggested-by Chris Wilson <[email protected]>Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
Quoted 5 lines
Quoted 2 lines
I'm not 100% sure this is what Chris was asking for v2, so please clarify if this is not what we want.
Does the trick for me,
Reviewed-by Chris Wilson <[email protected]>
Entire series merged to dinq, thanks.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx