FBC (+stolen) locking, v4
Subsystems (2)
cover FBC (+stolen) locking, v4
From: Paulo Zanoni <[email protected]>
Hi
So, based on the reviews, here's v4 of the series, now with dev_priv->mm.stolen_lock. This allows us to completely get rid of struct_mutex locking around FBC calls. Kudos to Chris for the suggestion.
The patch that added intel_fbc_stop() got removed from this series because the addition of mm.stolen_lock turned it into just an optimization instead of a bugfix. Let's leave it to another series, where I'll also try to clarify all the function names involved.
Since we didn't seem to reach any conclusions on the lockdep_assert_held vs WARN_ON discussion, I kept using WARN_ON since it's what the maintainer is asking and since it's what's winning in usage count. If we decide to change it, we can always do it in a later patch.
Thanks,
Paulo
Paulo Zanoni (7):
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
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 | 215 +++++++++-------------------- drivers/gpu/drm/i915/intel_display.c | 20 +-- drivers/gpu/drm/i915/intel_drv.h | 2 + drivers/gpu/drm/i915/intel_fbc.c | 239 ++++++++++++++++++++++++++++++--- 7 files changed, 309 insertions(+), 190 deletions(-)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/7 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. These abstractions will also allow us to add locking assertions later.
--- drivers/gpu/drm/i915/i915_drv.h | 4 ++++ drivers/gpu/drm/i915/i915_gem_stolen.c | 44 +++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +4 -0
@@ -3109,6 +3109,10 @@ 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_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 +28 -16
112 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/7 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.
--- drivers/gpu/drm/i915/i915_dma.c | 1 + drivers/gpu/drm/i915/i915_drv.h | 2 - drivers/gpu/drm/i915/i915_gem_stolen.c | 126 -------------------------------- drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_fbc.c | 128 ++++++++++++++++++++++++++++++++- 5 files changed, 127 insertions(+), 131 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
@@ -3114,8 +3114,6 @@ int i915_gem_stolen_insert_node(struct drm_i915_private *dev_priv, unsigned alignment);void i915_gem_stolen_remove_node (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 -126
138 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 +125 -3
146 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/7 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.
--- drivers/gpu/drm/i915/i915_drv.h | 7 +++- drivers/gpu/drm/i915/i915_gem_stolen.c | 69 +++++++++++++++++++++++----------- drivers/gpu/drm/i915/intel_fbc.c | 29 +++++++++++--- 3 files changed, 77 insertions(+), 28 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +6 -1
@@ -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;
@@ -3112,7 +3116,8 @@ static inline void i915_gem_chipset_flush(struct drm_device *dev)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_mm_node *node); +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);void i915_gem_cleanup_stolen (struct drm_device *dev); struct drm_i915_gem_object *
drivers/gpu/drm/i915/i915_gem_stolen.c +48 -21
167 lines not on this page · raw message
drivers/gpu/drm/i915/intel_fbc.c +23 -6
@@ -601,40 +601,57 @@ static int intel_fbc_alloc_cfb(struct drm_device *dev, int size, int fb_cpp) err_fb:kfree (compressed_llb); -i915_gem_stolen_remove_node (&dev_priv->fbc.compressed_fb); +i915_gem_stolen_remove_node (dev_priv, &dev_priv->fbc.compressed_fb); err_llb:pr_info_once ("drm: not enough stolen space for compressed buffer (need %d more bytes), disabling. Hint: you may be able to increase stolen memory size in the BIOS to avoid this.\n" , size);return -ENOSPC ; } -void intel_fbc_cleanup_cfb (struct drm_device *dev) +static void __intel_fbc_cleanup_cfb (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;if (dev_priv->fbc.uncompressed_size ==0 )return ; -i915_gem_stolen_remove_node (&dev_priv->fbc.compressed_fb); +i915_gem_stolen_remove_node (dev_priv, &dev_priv->fbc.compressed_fb);if (dev_priv->fbc.compressed_llb) { -i915_gem_stolen_remove_node (dev_priv->fbc.compressed_llb); +i915_gem_stolen_remove_node (dev_priv, + dev_priv->fbc.compressed_llb);kfree (dev_priv->fbc.compressed_llb); } dev_priv->fbc.uncompressed_size =0 ; } +void intel_fbc_cleanup_cfb (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; + +mutex_lock (&dev_priv->mm.stolen_lock); +__intel_fbc_cleanup_cfb (dev); +mutex_unlock (&dev_priv->mm.stolen_lock); +} +static int intel_fbc_setup_cfb (struct drm_device *dev,int size,int fb_cpp) {struct drm_i915_private *dev_priv = dev->dev_private; +int ret;if (size <= dev_priv->fbc.uncompressed_size)return 0 ; +mutex_lock (&dev_priv->mm.stolen_lock); +/* Release any current block */ -intel_fbc_cleanup_cfb (dev); +__intel_fbc_cleanup_cfb (dev); + + ret =intel_fbc_alloc_cfb (dev, size, fb_cpp); + +mutex_unlock (&dev_priv->mm.stolen_lock); -return intel_fbc_alloc_cfb (dev, size, fb_cpp); +return ret; }/**
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/7 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.
--- 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 | 94 +++++++++++++++++++++++++++++++----- 5 files changed, 91 insertions(+), 17 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 +81 -13
201 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/7 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/7 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/7 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
Re: [PATCH 3/7] drm/i915: add dev_priv->mm.stolen_lock
In reply to Paulo ZanoniQuoted 4 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.
Too coarse. The locking need only be around the stolen drm_mm, i.e. just insert/remove node. (And you don't need the lock around drm_mm_initialized, similarly teardown since like the init, they are serialised through other means.)
-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/7] drm/i915: add simple wrappers for stolen node insertion/removal
In reply to Paulo ZanoniQuoted 20 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. These abstractions will also allow us to add locking assertions later.Requested-by Chris Wilson <[email protected]>Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 4 ++++ drivers/gpu/drm/i915/i915_gem_stolen.c | 44 +++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 16 deletions(-)drivers/gpu/drm/i915/i915_drv.h +0
-0
drivers/gpu/drm/i915/i915_drv.h static inline void i915_gem_chipset_flush(struct drm_device *dev) · line 3115
Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.h +4
-0@@ -3109,6 +3109,10 @@ 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_mm_node *node);
Might as well pass in dev_priv now to save changing the interface later.
Quoted 8 lines
drivers/gpu/drm/i915/i915_drv.h +0
-0int 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 +0
-0
drivers/gpu/drm/i915/i915_gem_stolen.c line 50
Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_stolen.c +6
-0@@ -42,6 +42,22 @@* for is a boon. */ +int i915_gem_stolen_insert_node (struct drm_i915_private *dev_priv, +struct drm_mm_node *node,u64 size, +unsigned alignment) +{ +if (!drm_mm_initialized (&dev_priv->mm.stolen)) +return -ENODEV ;
Might as well take advantage of this test here to remove the same check from i915_gem_object_create_stolen_for_preallocated and i915_gem_object_create_stolen
Other than those minor, looks good.
-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 2/7] drm/i915: move FBC code out of i915_gem_stolen.c
In reply to Paulo ZanoniOn Wed, Jul 01, 2015 at 05:15:21PM -0300, Paulo Zanoni wrote:
Looks much cleaner with the split.
drivers/gpu/drm/i915/intel_fbc.c static struct drm_crtc *intel_fbc_find_crtc(struct drm_i915_private *dev_priv) · line 622
Quoted 13 lines
drivers/gpu/drm/i915/intel_fbc.c +13
-0+void intel_fbc_cleanup_cfb (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; + +if (dev_priv->fbc.uncompressed_size ==0 ) +return ; + +i915_gem_stolen_remove_node (&dev_priv->fbc.compressed_fb); + +if (dev_priv->fbc.compressed_llb) { +i915_gem_stolen_remove_node (dev_priv->fbc.compressed_llb); +kfree (dev_priv->fbc.compressed_llb); + }
Any reason why one node is embedded and the other allocated? Just feels a little inconsistent, so lacks an explanation. Just that one is always used, and the other on rare gen would probably suffice. -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 4/7] drm/i915: add the FBC mutex
In reply to Paulo ZanoniQuoted 23 lines · Paulo Zanoni
From: 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_lockfrom the previous patch, we can start removing thestruct_mutexlocking 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 forgetintel_pre_plane_update()locking.
v4:
- Don't removestruct_mutexatintel_pre_plane_update()(Chris).
- Add comment regarding locking dependencies (Chris).
- Rebase after the stolen code rework.
- Rebase again after drm-intel-nightly changes.
Quoted 1 line
Signed-off-by Paulo Zanoni <[email protected]>
See below.
drivers/gpu/drm/i915/intel_fbc.c void intel_fbc_update(struct drm_device *dev) · line 727
Quoted 8 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-0@@ -683,6 +721,8 @@ void intel_fbc_update(struct drm_device *dev)const struct drm_display_mode *adjusted_mode;unsigned int max_width, max_height; +WARN_ON (!mutex_is_locked (&dev_priv->fbc.lock)); +if (!HAS_FBC (dev))return ;
This is now __intel_fbc_update() inside the fbc.lock. One would think that the internal functions would only be called when FBC is desired.
That looks to be true, except for the new intel_fbc_update(). You can upgrade this to if (WARN_ON(!HAS_FBC(dev_priv))) return; after adding the proper guard to intel_fbc_update().
-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 7/7] drm/i915: FBC doesn't need struct_mutex anymore
In reply to Paulo ZanoniQuoted 7 lines · Paulo Zanoni
From: Paulo Zanoni <[email protected]>
Everything is covered either by fbc.lock or mm.stolen_lock, and
intel_fbc.cis already responsible for grabbing the appropriate locks when it needs them.Signed-off-by Paulo Zanoni <[email protected]>
5-7 Reviewed-by: Chris wilson <[email protected]>
They all look to be safely guarded by a specific mutex now. -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/7] drm/i915: add simple wrappers for stolen node insertion/removal
In reply to Chris Wilson2015-07-01 17:38 GMT-03:00 Chris Wilson <[email protected]>:
Quoted 23 lines · Paulo Zanoni
Quoted 22 lines
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. These abstractions will also allow us to add locking assertions later.Requested-by Chris Wilson <[email protected]>Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 4 ++++ drivers/gpu/drm/i915/i915_gem_stolen.c | 44 +++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 16 deletions(-)drivers/gpu/drm/i915/i915_drv.h +0
-0@@ -3109,6 +3109,10 @@ static inline void i915_gem_chipset_flush(struct drm_device *dev) }
Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.h static inline void i915_gem_chipset_flush(struct drm_device *dev) · line 3115
Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.h +4
-0/* 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_mm_node *node);Might as well pass in
dev_privnow to save changing the interface later.
I thought about doing it, but dev_priv is just for the mutex WARN, and I thought it could be rejected, so I didn't add dev_priv because of the risk of having the WARN rejected, so dev_priv would be useless. But I can change this, no problem.
Quoted 29 lines
Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.h +0
-0int 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 +0
-0drivers/gpu/drm/i915/i915_gem_stolen.c line 50
Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_stolen.c +6
-0@@ -42,6 +42,22 @@* for is a boon. */ +int i915_gem_stolen_insert_node (struct drm_i915_private *dev_priv, +struct drm_mm_node *node,u64 size, +unsigned alignment) +{ +if (!drm_mm_initialized (&dev_priv->mm.stolen)) +return -ENODEV ;Might as well take advantage of this test here to remove the same check from
i915_gem_object_create_stolen_for_preallocatedandi915_gem_object_create_stolenOther than those minor, looks good.
-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 1/7] drm/i915: add simple wrappers for stolen node insertion/removal
Quoted 32 lines · Paulo Zanoni
2015-07-01 17:38 GMT-03:00 Chris Wilson <[email protected]>:
Quoted 23 lines · Paulo Zanoni
Quoted 22 lines
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. These abstractions will also allow us to add locking assertions later.Requested-by Chris Wilson <[email protected]>Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 4 ++++ drivers/gpu/drm/i915/i915_gem_stolen.c | 44 +++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 16 deletions(-)drivers/gpu/drm/i915/i915_drv.h +0
-0@@ -3109,6 +3109,10 @@ static inline void i915_gem_chipset_flush(struct drm_device *dev) }Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.h static inline void i915_gem_chipset_flush(struct drm_device *dev) · line 3115
Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.h +4
-0/* 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_mm_node *node);Might as well pass in
dev_privnow to save changing the interface later.
Quoted 4 lines
I thought about doing it, but
dev_privis just for the mutex WARN, and I thought it could be rejected, so I didn't adddev_privbecause of the risk of having the WARN rejected, sodev_privwould be useless. But I can change this, no problem.
If you change it over to taking the stolen_mutex inside these functions (which is the only place we need to), then it is required. -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 2/7] drm/i915: move FBC code out of i915_gem_stolen.c
In reply to Chris Wilson2015-07-01 17:44 GMT-03:00 Chris Wilson <[email protected]>:
Quoted 13 lines · Paulo Zanoni
Looks much cleaner with the split.
Quoted 9 lines
drivers/gpu/drm/i915/intel_fbc.c +9
-0+void intel_fbc_cleanup_cfb (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; + +if (dev_priv->fbc.uncompressed_size ==0 ) +return ; + +i915_gem_stolen_remove_node (&dev_priv->fbc.compressed_fb); +
Quoted 8 lines
drivers/gpu/drm/i915/intel_fbc.c static struct drm_crtc *intel_fbc_find_crtc(struct drm_i915_private *dev_priv) · line 622
Quoted 4 lines
drivers/gpu/drm/i915/intel_fbc.c +4
-0+if (dev_priv->fbc.compressed_llb) { +i915_gem_stolen_remove_node (dev_priv->fbc.compressed_llb); +kfree (dev_priv->fbc.compressed_llb); + }Any reason why one node is embedded and the other allocated? Just feels a little inconsistent, so lacks an explanation. Just that one is always used, and the other on rare gen would probably suffice.
I really didn't stop to pay attention to the ancient FBC pieces. IMHO reasoning/explanation/change about this should be on a separate patch, since this one is just moving the code around.
I only think about the gen2-4 FBC code when I remember it has the "disable FBC when more than one pipe is visible" restriction which I can't even find on the documentation I have. I wish we could either remove it or just remove the whole gen2-4 FBC support (will we ever have the courage to enable it by default?).
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 2/7] drm/i915: move FBC code out of i915_gem_stolen.c
Quoted 27 lines · Paulo Zanoni
2015-07-01 17:44 GMT-03:00 Chris Wilson <[email protected]>:
Quoted 13 lines · Paulo Zanoni
Looks much cleaner with the split.
Quoted 9 lines
drivers/gpu/drm/i915/intel_fbc.c +9
-0+void intel_fbc_cleanup_cfb (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; + +if (dev_priv->fbc.uncompressed_size ==0 ) +return ; + +i915_gem_stolen_remove_node (&dev_priv->fbc.compressed_fb); +Quoted 8 lines
drivers/gpu/drm/i915/intel_fbc.c static struct drm_crtc *intel_fbc_find_crtc(struct drm_i915_private *dev_priv) · line 622
Quoted 4 lines
drivers/gpu/drm/i915/intel_fbc.c +4
-0+if (dev_priv->fbc.compressed_llb) { +i915_gem_stolen_remove_node (dev_priv->fbc.compressed_llb); +kfree (dev_priv->fbc.compressed_llb); + }Any reason why one node is embedded and the other allocated? Just feels a little inconsistent, so lacks an explanation. Just that one is always used, and the other on rare gen would probably suffice.
I really didn't stop to pay attention to the ancient FBC pieces. IMHO reasoning/explanation/change about this should be on a separate patch, since this one is just moving the code around.
Quoted 5 lines
I only think about the gen2-4 FBC code when I remember it has the "disable FBC when more than one pipe is visible" restriction which I can't even find on the documentation I have. I wish we could either remove it or just remove the whole gen2-4 FBC support (will we ever have the courage to enable it by default?).
Oh, no worries, that is how the code was is no problem. It just stood out as inconsistent and hence made me stop and think when reviewing.
Might as well make them the same whilst we are here so I don't ask stupid questions.
-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/7] drm/i915: add simple wrappers for stolen node insertion/removal
In reply to Chris Wilson2015-07-01 17:38 GMT-03:00 Chris Wilson <[email protected]>:
Quoted 43 lines · Paulo Zanoni
Quoted 20 lines
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. These abstractions will also allow us to add locking assertions later.Requested-by Chris Wilson <[email protected]>Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 4 ++++ drivers/gpu/drm/i915/i915_gem_stolen.c | 44 +++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 16 deletions(-)drivers/gpu/drm/i915/i915_drv.h +0
-0drivers/gpu/drm/i915/i915_drv.h static inline void i915_gem_chipset_flush(struct drm_device *dev) · line 3115
Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.h +4
-0@@ -3109,6 +3109,10 @@ 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_mm_node *node);Might as well pass in
dev_privnow to save changing the interface later.Quoted 11 lines
drivers/gpu/drm/i915/i915_drv.h +0
-0int 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 +0
-0@@ -42,6 +42,22 @@* for is a boon. */
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_stolen.c line 50
Quoted 6 lines
drivers/gpu/drm/i915/i915_gem_stolen.c +6
-0+int i915_gem_stolen_insert_node (struct drm_i915_private *dev_priv, +struct drm_mm_node *node,u64 size, +unsigned alignment) +{ +if (!drm_mm_initialized (&dev_priv->mm.stolen)) +return -ENODEV ;Might as well take advantage of this test here to remove the same check from
i915_gem_object_create_stolen_for_preallocatedandi915_gem_object_create_stolen
If we do this, we'll start printing "creating stolen something" and "failed to alloc stolen node" messages even when stolen is not present, and we'll also do some useless alloc+free calls.
For the specific case of i915_gem_object_create_stolen_for_preallocated(), we'll then run drm_mm_reserve_node() without doing the check first, and a brief look at the implementation suggests it would probably fail with a non-initialized mm.stolen (it seems drm_mm_for_each_hole() assumes the hole_stack list is initialized). So we'd need to reorganize the function first, and the result would be a code that is a little more fragile.
It looks like i915_gem_object_create_stolen() would survive without the drm_mm_initialized(), but it would still have useless alloc/free calls and debug messages.
Based on that, and on the fact that drm_mm_initialized() is a simple inline pointer check, I'd vote to not remove the drm_mm_initialized() calls.
Quoted 6 lines
Other than those minor, looks good.
-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 1/7] drm/i915: add simple wrappers for stolen node insertion/removal
Quoted 55 lines · Paulo Zanoni
2015-07-01 17:38 GMT-03:00 Chris Wilson <[email protected]>:
Quoted 43 lines · Paulo Zanoni
Quoted 20 lines
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. These abstractions will also allow us to add locking assertions later.Requested-by Chris Wilson <[email protected]>Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 4 ++++ drivers/gpu/drm/i915/i915_gem_stolen.c | 44 +++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 16 deletions(-)drivers/gpu/drm/i915/i915_drv.h +0
-0drivers/gpu/drm/i915/i915_drv.h static inline void i915_gem_chipset_flush(struct drm_device *dev) · line 3115
Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.h +4
-0@@ -3109,6 +3109,10 @@ 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_mm_node *node);Might as well pass in
dev_privnow to save changing the interface later.Quoted 11 lines
drivers/gpu/drm/i915/i915_drv.h +0
-0int 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 +0
-0@@ -42,6 +42,22 @@* for is a boon. */ Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_stolen.c line 50
Quoted 6 lines
drivers/gpu/drm/i915/i915_gem_stolen.c +6
-0+int i915_gem_stolen_insert_node (struct drm_i915_private *dev_priv, +struct drm_mm_node *node,u64 size, +unsigned alignment) +{ +if (!drm_mm_initialized (&dev_priv->mm.stolen)) +return -ENODEV ;Might as well take advantage of this test here to remove the same check from
i915_gem_object_create_stolen_for_preallocatedandi915_gem_object_create_stolen
Quoted 3 lines
If we do this, we'll start printing "creating stolen something" and "failed to alloc stolen node" messages even when stolen is not present, and we'll also do some useless alloc+free calls.
The messages we can delete if you think they are a nuisance, certainly error ones here tend to be (since we often use stolen then failsafe).
Quoted 8 lines
For the specific case of
i915_gem_object_create_stolen_for_preallocated(), we'll then rundrm_mm_reserve_node()without doing the check first, and a brief look at the implementation suggests it would probably fail with a non-initialized mm.stolen (it seemsdrm_mm_for_each_hole()assumes thehole_stacklist is initialized). So we'd need to reorganize the function first, and the result would be a code that is a little more fragile.
Ok, that's a nuisance. I was just trying to think of a way to trim a few lines of code.
Quoted 7 lines
It looks like
i915_gem_object_create_stolen()would survive without thedrm_mm_initialized(), but it would still have useless alloc/free calls and debug messages.Based on that, and on the fact that
drm_mm_initialized()is a simple inline pointer check, I'd vote to not remove thedrm_mm_initialized()calls.
Ok.
-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 4/7] drm/i915: add the FBC mutex
In reply to Chris Wilson2015-07-01 17:49 GMT-03:00 Chris Wilson <[email protected]>:
Quoted 42 lines · Paulo Zanoni
Quoted 23 lines
From: 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_lockfrom the previous patch, we can start removing thestruct_mutexlocking 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 forgetintel_pre_plane_update()locking.
v4:
- Don't removestruct_mutexatintel_pre_plane_update()(Chris).
- Add comment regarding locking dependencies (Chris).
- Rebase after the stolen code rework.
- Rebase again after drm-intel-nightly changes.Quoted 1 line
Signed-off-by Paulo Zanoni <[email protected]>Reviewed-by Chris Wilson <[email protected]>See below.
drivers/gpu/drm/i915/intel_fbc.c void intel_fbc_update(struct drm_device *dev) · line 727
Quoted 8 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-0@@ -683,6 +721,8 @@ void intel_fbc_update(struct drm_device *dev)const struct drm_display_mode *adjusted_mode;unsigned int max_width, max_height; +WARN_ON (!mutex_is_locked (&dev_priv->fbc.lock)); +if (!HAS_FBC (dev))return ;This is now
__intel_fbc_update()inside the fbc.lock. One would think that the internal functions would only be called when FBC is desired.
Quoted 3 lines
That looks to be true, except for the new
intel_fbc_update(). You can upgrade this to if (WARN_ON(!HAS_FBC(dev_priv))) return; after adding the proper guard tointel_fbc_update().
__intel_fbc_update() is also called by intel_fbc_flush(). See "[PATCH 8/8] drm/i915: protect FBC functions with HAS_FBC checks" on the new series. I still have another series just with minor changes like this which I intend to send after the locking series.
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 1/7] drm/i915: add simple wrappers for stolen node insertion/removal
In reply to Paulo ZanoniQuoted 10 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. These abstractions will also allow us to add locking assertions later.Requested-by Chris Wilson <[email protected]>Signed-off-by Paulo Zanoni <[email protected]>
I guess you'll follow up with a nice kerneldoc patch for i915_gem_stolen? You're the expert on this code now ;-)
Cheers, Daniel
Quoted 154 lines
--- drivers/gpu/drm/i915/i915_drv.h | 4 ++++ drivers/gpu/drm/i915/i915_gem_stolen.c | 44 +++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 16 deletions(-)drivers/gpu/drm/i915/i915_drv.h +4
-0@@ -3109,6 +3109,10 @@ 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_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 +28
-16@@ -42,6 +42,22 @@* for is a boon. */ +int i915_gem_stolen_insert_node (struct drm_i915_private *dev_priv, +struct drm_mm_node *node,u64 size, +unsigned alignment) +{ +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 ); +} + +void i915_gem_stolen_remove_node (struct drm_mm_node *node) +{ +drm_mm_remove_node (node); +} +static unsigned long i915_stolen_to_physical (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;@@ -168,8 +184,7 @@ static int find_compression_threshold(struct drm_device *dev,*/ /* Try to over-allocate to reduce reallocations and fragmentation. */ - ret =drm_mm_insert_node (&dev_priv->mm.stolen, node, - size <<=1 ,4096 ,DRM_MM_SEARCH_DEFAULT ); + ret =i915_gem_stolen_insert_node (dev_priv, node, size <<=1 ,4096 );if (ret ==0 )return compression_threshold;@@ -179,9 +194,7 @@ again: (fb_cpp == 2 && compression_threshold == 2))return 0 ; - ret =drm_mm_insert_node (&dev_priv->mm.stolen, node, - size >>=1 ,4096 , -DRM_MM_SEARCH_DEFAULT ); + ret =i915_gem_stolen_insert_node (dev_priv, node, size >>=1 ,4096 );if (ret &&INTEL_INFO (dev)->gen <=4 ) {return 0 ; }else if (ret) {@@ -218,8 +231,8 @@ static int i915_setup_compression(struct drm_device *dev, int size, int fb_cpp)if (!compressed_llb) goto err_fb; - ret =drm_mm_insert_node (&dev_priv->mm.stolen, compressed_llb, -4096 ,4096 ,DRM_MM_SEARCH_DEFAULT ); + ret =i915_gem_stolen_insert_node (dev_priv, compressed_llb, +4096 ,4096 );if (ret) goto err_fb;@@ -240,7 +253,7 @@ static int i915_setup_compression(struct drm_device *dev, int size, int fb_cpp) err_fb:kfree (compressed_llb); -drm_mm_remove_node (&dev_priv->fbc.compressed_fb); +i915_gem_stolen_remove_node (&dev_priv->fbc.compressed_fb); err_llb:pr_info_once ("drm: not enough stolen space for compressed buffer (need %d more bytes), disabling. Hint: you may be able to increase stolen memory size in the BIOS to avoid this.\n" , size);return -ENOSPC ;@@ -269,10 +282,10 @@ void i915_gem_stolen_cleanup_compression(struct drm_device *dev)if (dev_priv->fbc.uncompressed_size ==0 )return ; -drm_mm_remove_node (&dev_priv->fbc.compressed_fb); +i915_gem_stolen_remove_node (&dev_priv->fbc.compressed_fb);if (dev_priv->fbc.compressed_llb) { -drm_mm_remove_node (dev_priv->fbc.compressed_llb); +i915_gem_stolen_remove_node (dev_priv->fbc.compressed_llb);kfree (dev_priv->fbc.compressed_llb); }@@ -387,7 +400,7 @@ static void i915_gem_object_release_stolen(struct drm_i915_gem_object *obj) {if (obj->stolen) { -drm_mm_remove_node (obj->stolen); +i915_gem_stolen_remove_node (obj->stolen);kfree (obj->stolen); obj->stolen =NULL ; }@@ -449,8 +462,7 @@ i915_gem_object_create_stolen(struct drm_device *dev, u32 size)if (!stolen)return NULL ; - ret =drm_mm_insert_node (&dev_priv->mm.stolen, stolen, size, -4096 ,DRM_MM_SEARCH_DEFAULT ); + ret =i915_gem_stolen_insert_node (dev_priv, stolen, size,4096 );if (ret) {kfree (stolen);return NULL ;@@ -460,7 +472,7 @@ i915_gem_object_create_stolen(struct drm_device *dev, u32 size)if (obj)return obj; -drm_mm_remove_node (stolen); +i915_gem_stolen_remove_node (stolen);kfree (stolen);return NULL ; }@@ -505,7 +517,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, obj =_i915_gem_object_create_stolen (dev, stolen);if (obj ==NULL ) {DRM_DEBUG_KMS ("failed to allocate stolen object\n" ); -drm_mm_remove_node (stolen); +i915_gem_stolen_remove_node (stolen);kfree (stolen);return NULL ; }@@ -546,7 +558,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, err_vma:i915_gem_vma_destroy (vma); err_out: -drm_mm_remove_node (stolen); +i915_gem_stolen_remove_node (stolen);kfree (stolen);drm_gem_object_unreference (&obj->base);return NULL ;Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
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
Re: [PATCH 2/7] drm/i915: move FBC code out of i915_gem_stolen.c
In reply to Paulo ZanoniQuoted 27 lines · Paulo Zanoni
2015-07-01 17:44 GMT-03:00 Chris Wilson <[email protected]>:
Quoted 13 lines · Paulo Zanoni
Looks much cleaner with the split.
Quoted 9 lines
drivers/gpu/drm/i915/intel_fbc.c +9
-0+void intel_fbc_cleanup_cfb (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; + +if (dev_priv->fbc.uncompressed_size ==0 ) +return ; + +i915_gem_stolen_remove_node (&dev_priv->fbc.compressed_fb); +Quoted 8 lines
drivers/gpu/drm/i915/intel_fbc.c static struct drm_crtc *intel_fbc_find_crtc(struct drm_i915_private *dev_priv) · line 622
Quoted 4 lines
drivers/gpu/drm/i915/intel_fbc.c +4
-0+if (dev_priv->fbc.compressed_llb) { +i915_gem_stolen_remove_node (dev_priv->fbc.compressed_llb); +kfree (dev_priv->fbc.compressed_llb); + }Any reason why one node is embedded and the other allocated? Just feels a little inconsistent, so lacks an explanation. Just that one is always used, and the other on rare gen would probably suffice.
I really didn't stop to pay attention to the ancient FBC pieces. IMHO reasoning/explanation/change about this should be on a separate patch, since this one is just moving the code around.
Quoted 5 lines
I only think about the gen2-4 FBC code when I remember it has the "disable FBC when more than one pipe is visible" restriction which I can't even find on the documentation I have. I wish we could either remove it or just remove the whole gen2-4 FBC support (will we ever have the courage to enable it by default?).
Yeah I think killing gen2-4 fbc would be ok. Same for g4x fbc (hw too broken) and ilk fbc (same really according to Art). Then we'd only need to deal with fbc on gen6+, which is reasonably sane and consistent.
But we can rip the code out whenever you want, no hurry. -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