drm/vc4: Add a load tracker
Subsystems (3)
v5 cover drm/vc4: Add a load tracker
Hi,
Here is a fourth iteration of the VC4 load tracking series, which was initially developed by Boris Brezillon and that I have now taken over.
This new iteration takes in account comments from v3 and comes with a new approach for avoiding underrun reports when reconfiguring the pipeline. It is now based on detection instead of delaying the underrun interrupt unmasking.
It can be tested with a dedicated IGT GPU Tools series:
VC4 load tracker testing
Changes since v4:
* Unmasked underrun in vc4_crtc_handle_page_flip instead of the previous workaround for detecting out-of-sync display lists causing underruns;
* Added comments where it felt relevant;
* Made underrun masking/unmasking per-channel to avoid race conditions resulting in unwanted masking/unmasking;
* Added a check for unmasked interrupt before acting upon it;
* Disabled shortline/underrun interrupts at initial config time;
* Added collected Reviewed-by tags.
Changes since v3:
* Returned IRQ_NONE for short line interrupt to avoid storm;
* Made register definitions with per-channel offsets more direct;
* cleaned all IRQ fields instead of writing back the status bit as advised by docs;
* Reworked first commit's message;
* Removed in-commit changelogs with inconsistent revision numbers;
* Removed explicit wait for sync before unmasking underrun interrupt;
* Checked that the display lists are synced before reporting underrun;
Cheers,
Paul
Boris Brezillon (2):
drm/vc4: Report HVS underrun errors
drm/vc4: Add a load tracker to prevent HVS underflow errors
Paul Kocialkowski (1):
drm/vc4: Add a debugfs entry to disable/enable the load tracker
drivers/gpu/drm/vc4/vc4_crtc.c | 8 ++ drivers/gpu/drm/vc4/vc4_debugfs.c | 10 +++ drivers/gpu/drm/vc4/vc4_drv.c | 1 + drivers/gpu/drm/vc4/vc4_drv.h | 24 ++++++ drivers/gpu/drm/vc4/vc4_hvs.c | 95 +++++++++++++++++++++++ drivers/gpu/drm/vc4/vc4_kms.c | 122 +++++++++++++++++++++++++++++- drivers/gpu/drm/vc4/vc4_plane.c | 57 ++++++++++++++ drivers/gpu/drm/vc4/vc4_regs.h | 51 ++++--------- 8 files changed, 332 insertions(+), 36 deletions(-)
Signature · 1 line
2.20.1
PATCH v5 1/3 drm/vc4: Report HVS underrun errors
From: Boris Brezillon <[email protected]>
Add a debugfs entry and helper for reporting HVS underrun errors as well as helpers for masking and unmasking the underrun interrupts. Add an IRQ handler and initial IRQ configuration.
Rework related register definitions to take the channel number.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 8 +++ drivers/gpu/drm/vc4/vc4_debugfs.c | 1 + drivers/gpu/drm/vc4/vc4_drv.h | 10 ++++ drivers/gpu/drm/vc4/vc4_hvs.c | 95 +++++++++++++++++++++++++++++++ drivers/gpu/drm/vc4/vc4_kms.c | 10 ++++ drivers/gpu/drm/vc4/vc4_regs.h | 51 ++++++----------- 6 files changed, 140 insertions(+), 35 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +8 -0
@@ -834,6 +834,14 @@ static void vc4_crtc_handle_page_flip(struct vc4_crtc *vc4_crtc)drm_crtc_send_vblank_event (crtc, vc4_crtc->event); vc4_crtc->event =NULL ;drm_crtc_vblank_put (crtc); + +/* Wait for the page flip to unmask the underrun to ensure that +* the display list was updated by the hardware. Before that +* happens, the HVS will be using the previous display list with +* the CRTC and encoder already reconfigured, leading to +* underruns. This can be seen when reconfiguring the CRTC. +*/ +vc4_hvs_unmask_underrun (dev, vc4_crtc->channel); }spin_unlock_irqrestore (&dev->event_lock, flags); }
drivers/gpu/drm/vc4/vc4_debugfs.c +1 -0
@@ -23,6 +23,7 @@ static const struct drm_info_list vc4_debugfs_list[] = { {"vec_regs", vc4_vec_debugfs_regs, 0}, {"txp_regs", vc4_txp_debugfs_regs, 0}, {"hvs_regs", vc4_hvs_debugfs_regs, 0}, + {"hvs_underrun", vc4_hvs_debugfs_underrun, 0}, {"crtc0_regs", vc4_crtc_debugfs_regs, 0, (void *)(uintptr_t)0}, {"crtc1_regs", vc4_crtc_debugfs_regs, 0, (void *)(uintptr_t)1}, {"crtc2_regs", vc4_crtc_debugfs_regs, 0, (void *)(uintptr_t)2},
drivers/gpu/drm/vc4/vc4_drv.h +10 -0
@@ -184,6 +184,13 @@ struct vc4_dev {/* Bitmask of the current bin_alloc used for overflow memory. */ uint32_t bin_alloc_overflow; +/* Incremented when an underrun error happened after an atomic commit. +* This is particularly useful to detect when a specific modeset is too +* demanding in term of memory or HVS bandwidth which is hard to guess +* at atomic check time. +*/ +atomic_t underrun; +struct work_struct overflow_mem_work;int power_refcount;
@@ -767,6 +774,9 @@ void vc4_irq_reset(struct drm_device *dev);extern struct platform_driver vc4_hvs_driver;void vc4_hvs_dump_state (struct drm_device *dev);int vc4_hvs_debugfs_regs (struct seq_file *m,void *unused); +int vc4_hvs_debugfs_underrun (struct seq_file *m,void *unused); +void vc4_hvs_unmask_underrun (struct drm_device *dev,int channel); +void vc4_hvs_mask_underrun (struct drm_device *dev,int channel);/* vc4_kms.c */ int vc4_kms_load (struct drm_device *dev);
drivers/gpu/drm/vc4/vc4_hvs.c +95 -0
128 lines not on this page · raw message
drivers/gpu/drm/vc4/vc4_kms.c +10 -0
@@ -138,6 +138,16 @@ vc4_atomic_complete_commit(struct drm_atomic_state *state) {struct drm_device *dev = state->dev;struct vc4_dev *vc4 =to_vc4_dev (dev); +struct vc4_crtc *vc4_crtc; +int i; + +for (i =0 ; i < dev->mode_config.num_crtc; i++) { +if (!state->crtcs[i].ptr || !state->crtcs[i].commit) +continue ; + + vc4_crtc =to_vc4_crtc (state->crtcs[i].ptr); +vc4_hvs_mask_underrun (dev, vc4_crtc->channel); + }drm_atomic_helper_wait_for_fences (dev, state, false);
drivers/gpu/drm/vc4/vc4_regs.h +16 -35
107 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v5 2/3 drm/vc4: Add a load tracker to prevent HVS underflow errors
In reply to Paul KocialkowskiFrom: Boris Brezillon <[email protected]>
The HVS block is supposed to fill the pixelvalve FIFOs fast enough to meet the requested framerate. The problem is, the HVS and memory bus bandwidths are limited, and if we don't take these limitations into account we might end up with HVS underflow errors.
This patch is trying to model the per-plane HVS and memory bus bandwidth consumption and take a decision at atomic_check() time whether the estimated load will fit in the HVS and membus budget.
Note that we take an extra margin on the memory bus consumption to let the system run smoothly when other blocks are doing heavy use of the memory bus. Same goes for the HVS limit, except the margin is smaller in this case, since the HVS is not used by external components.
--- drivers/gpu/drm/vc4/vc4_drv.c | 1 + drivers/gpu/drm/vc4/vc4_drv.h | 11 ++++ drivers/gpu/drm/vc4/vc4_kms.c | 103 +++++++++++++++++++++++++++++++- drivers/gpu/drm/vc4/vc4_plane.c | 57 ++++++++++++++++++ 4 files changed, 171 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_drv.c +1 -0
@@ -311,6 +311,7 @@ static void vc4_drm_unbind(struct device *dev)drm_mode_config_cleanup (drm); +drm_atomic_private_obj_fini (&vc4->load_tracker);drm_atomic_private_obj_fini (&vc4->ctm_manager);drm_dev_put (drm);
drivers/gpu/drm/vc4/vc4_drv.h +11 -0
@@ -207,6 +207,7 @@ struct vc4_dev {struct drm_modeset_lock ctm_state_lock;struct drm_private_obj ctm_manager; +struct drm_private_obj load_tracker; }; static inline struct vc4_dev *
@@ -378,6 +379,16 @@ struct vc4_plane_state {* when async update is not possible. */ bool dlist_initialized; + +/* Load of this plane on the HVS block. The load is expressed in HVS +* cycles/sec. +*/ +u64 hvs_load; + +/* Memory bandwidth needed for this plane. This is expressed in +* bytes/sec. +*/ +u64 membus_load; }; static inline struct vc4_plane_state *
drivers/gpu/drm/vc4/vc4_kms.c +102 -1
133 lines not on this page · raw message
drivers/gpu/drm/vc4/vc4_plane.c +57 -0
69 lines not on this page · raw message
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 3/3 drm/vc4: Add a debugfs entry to disable/enable the load tracker
In reply to Paul KocialkowskiIn order to test whether the load tracker is working as expected, we need the ability to compare the commit result with the underrun indication. With the load tracker always enabled, commits that are expected to trigger an underrun are always rejected, so userspace cannot get the actual underrun indication from the hardware.
Add a debugfs entry to disable/enable the load tracker, so that a DRM commit expected to trigger an underrun can go through with the load tracker disabled. The underrun indication is then available to userspace and can be checked against the commit result with the load tracker enabled.
--- drivers/gpu/drm/vc4/vc4_debugfs.c | 9 +++++++++ drivers/gpu/drm/vc4/vc4_drv.h | 3 +++ drivers/gpu/drm/vc4/vc4_kms.c | 9 +++++++++ 3 files changed, 21 insertions(+)
drivers/gpu/drm/vc4/vc4_debugfs.c +9 -0
@@ -36,6 +36,15 @@ static const struct drm_info_list vc4_debugfs_list[] = {int vc4_debugfs_init (struct drm_minor *minor) { +struct vc4_dev *vc4 =to_vc4_dev (minor->dev); +struct dentry *dentry; + + dentry =debugfs_create_bool ("hvs_load_tracker" ,S_IRUGO |S_IWUSR , + minor->debugfs_root, + &vc4->load_tracker_enabled); +if (!dentry) +return -ENOMEM ; +return drm_debugfs_create_files (vc4_debugfs_list,VC4_DEBUGFS_ENTRIES , minor->debugfs_root, minor); }
drivers/gpu/drm/vc4/vc4_drv.h +3 -0
@@ -195,6 +195,9 @@ struct vc4_dev {int power_refcount; +/* Set to true when the load tracker is active. */ +bool load_tracker_enabled; +/* Mutex controlling the power refcount. */ struct mutex power_lock;
drivers/gpu/drm/vc4/vc4_kms.c +9 -0
@@ -439,6 +439,10 @@ static int vc4_load_tracker_atomic_check(struct drm_atomic_state *state) } } +/* Don't check the load when the tracker is disabled. */ +if (!vc4->load_tracker_enabled) +return 0 ; +/* The absolute limit is 2Gbyte/sec, but let's take a margin to let * the system work when other blocks are accessing the memory. */
@@ -511,6 +515,11 @@ int vc4_kms_load(struct drm_device *dev)struct vc4_load_tracker_state *load_state;int ret; +/* Start with the load tracker enabled. Can be disabled through the +* debugfs load_tracker file. +*/ + vc4->load_tracker_enabled = true; +sema_init (&vc4->async_modeset,1 );/* Set support for vblank irq fast disable, before drm_vblank_init() */
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 5 lines · Paul Kocialkowski
Hi,
Here is a fourth iteration of the VC4 load tracking series, which was initially developed by Boris Brezillon and that I have now taken over.
Quoted 7 lines
This new iteration takes in account comments from v3 and comes with a new approach for avoiding underrun reports when reconfiguring the pipeline. It is now based on detection instead of delaying the underrun interrupt unmasking.
It can be tested with a dedicated IGT GPU Tools series:
VC4 load tracker testing
Series is:
Thanks for persisting on this!
Maxime Ripard
AppliedQuoted 12 lines · Eric Anholt
Quoted 10 lines · Paul Kocialkowski
Hi,
Here is a fourth iteration of the VC4 load tracking series, which was initially developed by Boris Brezillon and that I have now taken over.
This new iteration takes in account comments from v3 and comes with a new approach for avoiding underrun reports when reconfiguring the pipeline. It is now based on detection instead of delaying the underrun interrupt unmasking.
Quoted 8 lines
Quoted 2 lines
It can be tested with a dedicated IGT GPU Tools series:
VC4 load tracker testingSeries is:
Reviewed-by Eric Anholt <[email protected]>Thanks for persisting on this!
Applied all three patches to drm-misc-next.
Maxime
Signature · 3 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com