drm/vc4: Add a load tracker
Subsystems (3)
v4 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 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 (2):
drm/vc4: Detect and ignore underruns caused by out-of-sync dlists drm/vc4: Add a debugfs entry to disable/enable the load tracker
drivers/gpu/drm/vc4/vc4_debugfs.c | 10 +++ drivers/gpu/drm/vc4/vc4_drv.c | 1 + drivers/gpu/drm/vc4/vc4_drv.h | 32 ++++++++ drivers/gpu/drm/vc4/vc4_hvs.c | 123 ++++++++++++++++++++++++++++++ drivers/gpu/drm/vc4/vc4_kms.c | 116 +++++++++++++++++++++++++++- drivers/gpu/drm/vc4/vc4_plane.c | 57 ++++++++++++++ drivers/gpu/drm/vc4/vc4_regs.h | 51 ++++--------- 7 files changed, 354 insertions(+), 36 deletions(-)
Signature · 1 line
2.20.1
PATCH v4 1/4 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_debugfs.c | 1 + drivers/gpu/drm/vc4/vc4_drv.h | 10 ++++ drivers/gpu/drm/vc4/vc4_hvs.c | 92 +++++++++++++++++++++++++++++++ drivers/gpu/drm/vc4/vc4_kms.c | 4 ++ drivers/gpu/drm/vc4/vc4_regs.h | 49 +++++----------- 5 files changed, 121 insertions(+), 35 deletions(-)
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
@@ -185,6 +185,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;
@@ -773,6 +780,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); +void vc4_hvs_mask_underrun (struct drm_device *dev);/* vc4_kms.c */ int vc4_kms_load (struct drm_device *dev);
drivers/gpu/drm/vc4/vc4_hvs.c +92 -0
125 lines not on this page · raw message
drivers/gpu/drm/vc4/vc4_kms.c +4 -0
@@ -139,6 +139,8 @@ vc4_atomic_complete_commit(struct drm_atomic_state *state)struct drm_device *dev = state->dev;struct vc4_dev *vc4 =to_vc4_dev (dev); +vc4_hvs_mask_underrun (dev); +drm_atomic_helper_wait_for_fences (dev, state, false);drm_atomic_helper_wait_for_dependencies (state);
@@ -155,6 +157,8 @@ vc4_atomic_complete_commit(struct drm_atomic_state *state)drm_atomic_helper_commit_hw_done (state); +vc4_hvs_unmask_underrun (dev); +drm_atomic_helper_wait_for_flip_done (dev, state);drm_atomic_helper_cleanup_planes (dev, state);
drivers/gpu/drm/vc4/vc4_regs.h +14 -35
102 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH v4 1/4] drm/vc4: Report HVS underrun errors
Quoted 204 lines · Paul Kocialkowski
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.Signed-off-by Boris Brezillon <[email protected]>Signed-off-by Paul Kocialkowski <[email protected]>--- drivers/gpu/drm/vc4/vc4_debugfs.c | 1 + drivers/gpu/drm/vc4/vc4_drv.h | 10 ++++ drivers/gpu/drm/vc4/vc4_hvs.c | 92 +++++++++++++++++++++++++++++++ drivers/gpu/drm/vc4/vc4_kms.c | 4 ++ drivers/gpu/drm/vc4/vc4_regs.h | 49 +++++----------- 5 files changed, 121 insertions(+), 35 deletions(-)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@@ -185,6 +185,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;@@ -773,6 +780,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); +void vc4_hvs_mask_underrun (struct drm_device *dev);/* vc4_kms.c */ int vc4_kms_load (struct drm_device *dev);drivers/gpu/drm/vc4/vc4_hvs.c +92
-0@@ -22,6 +22,7 @@* each CRTC. */ +#include <drm/drm_atomic_helper.h> #include <linux/component.h> #include "vc4_drv.h" #include "vc4_regs.h" @@ -102,6 +103,18 @@ int vc4_hvs_debugfs_regs(struct seq_file *m, void *unused) return 0; } + +int vc4_hvs_debugfs_underrun (struct seq_file *m,void *data) +{ +struct drm_info_node *node = m->private; +struct drm_device *dev = node->minor->dev; +struct vc4_dev *vc4 =to_vc4_dev (dev); +struct drm_printer p =drm_seq_file_printer (m); + +drm_printf (&p,"%d\n" ,atomic_read (&vc4->underrun)); + +return 0 ; +}#endif /* The filter kernel is composed of dwords each containing 3 9-bit @@ -166,6 +179,67 @@ static int vc4_hvs_upload_linear_kernel(struct vc4_hvs *hvs,return 0 ; } +void vc4_hvs_mask_underrun (struct drm_device *dev) +{ +struct vc4_dev *vc4 =to_vc4_dev (dev); +u32 dispctrl =HVS_READ (SCALER_DISPCTRL ); + + dispctrl &= ~(SCALER_DISPCTRL_DSPEISLUR (0 ) | +SCALER_DISPCTRL_DSPEISLUR (1 ) | +SCALER_DISPCTRL_DSPEISLUR (2 )); + +HVS_WRITE (SCALER_DISPCTRL , dispctrl); +} + +void vc4_hvs_unmask_underrun (struct drm_device *dev) +{ +struct vc4_dev *vc4 =to_vc4_dev (dev); +u32 dispctrl =HVS_READ (SCALER_DISPCTRL ); + + dispctrl |=SCALER_DISPCTRL_DSPEISLUR (0 ) | +SCALER_DISPCTRL_DSPEISLUR (1 ) | +SCALER_DISPCTRL_DSPEISLUR (2 ); + +HVS_WRITE (SCALER_DISPSTAT , +SCALER_DISPSTAT_EUFLOW (0 ) | +SCALER_DISPSTAT_EUFLOW (1 ) | +SCALER_DISPSTAT_EUFLOW (2 )); +HVS_WRITE (SCALER_DISPCTRL , dispctrl); +} + +static void vc4_hvs_report_underrun (struct drm_device *dev) +{ +struct vc4_dev *vc4 =to_vc4_dev (dev); + +atomic_inc (&vc4->underrun); +DRM_DEV_ERROR (dev->dev,"HVS underrun\n" ); +} + +static irqreturn_t vc4_hvs_irq_handler (int irq,void *data) +{ +struct drm_device *dev = data; +struct vc4_dev *vc4 =to_vc4_dev (dev); +irqreturn_t irqret =IRQ_NONE ; +u32 status; + + status =HVS_READ (SCALER_DISPSTAT ); + +if (status & (SCALER_DISPSTAT_EUFLOW (0 ) | +SCALER_DISPSTAT_EUFLOW (1 ) | +SCALER_DISPSTAT_EUFLOW (2 ))) { +vc4_hvs_mask_underrun (dev); +vc4_hvs_report_underrun (dev); + + irqret =IRQ_HANDLED ; + } + +HVS_WRITE (SCALER_DISPSTAT ,SCALER_DISPSTAT_IRQMASK (0 ) | +SCALER_DISPSTAT_IRQMASK (1 ) | +SCALER_DISPSTAT_IRQMASK (2 )); + +return irqret; +} +static int vc4_hvs_bind (struct device *dev,struct device *master,void *data) {struct platform_device *pdev =to_platform_device (dev);@@ -219,15 +293,33 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data) dispctrl =HVS_READ (SCALER_DISPCTRL ); dispctrl |=SCALER_DISPCTRL_ENABLE ; + dispctrl |=SCALER_DISPCTRL_DSPEISLUR (0 ) |SCALER_DISPCTRL_DISPEIRQ (0 ) | +SCALER_DISPCTRL_DSPEISLUR (1 ) |SCALER_DISPCTRL_DISPEIRQ (1 ) | +SCALER_DISPCTRL_DSPEISLUR (2 ) |SCALER_DISPCTRL_DISPEIRQ (2 );/* Set DSP3 (PV1) to use HVS channel 2, which would otherwise * be unused. */ dispctrl &= ~SCALER_DISPCTRL_DSP3_MUX_MASK ; + dispctrl &= ~(SCALER_DISPCTRL_DMAEIRQ | +SCALER_DISPCTRL_SLVWREIRQ | +SCALER_DISPCTRL_SLVRDEIRQ | +SCALER_DISPCTRL_DSPEIEOF (0 ) | +SCALER_DISPCTRL_DSPEIEOF (1 ) | +SCALER_DISPCTRL_DSPEIEOF (2 ) | +SCALER_DISPCTRL_DSPEIEOLN (0 ) | +SCALER_DISPCTRL_DSPEIEOLN (1 ) | +SCALER_DISPCTRL_DSPEIEOLN (2 ) | +SCALER_DISPCTRL_SCLEIRQ ); dispctrl |=VC4_SET_FIELD (2 ,SCALER_DISPCTRL_DSP3_MUX );HVS_WRITE (SCALER_DISPCTRL , dispctrl); + ret =devm_request_irq (dev,platform_get_irq (pdev,0 ), + vc4_hvs_irq_handler,0 ,"vc4 hvs" , drm); +if (ret) +return ret; +return 0 ; }drivers/gpu/drm/vc4/vc4_kms.c +2
-0@@ -139,6 +139,8 @@ vc4_atomic_complete_commit(struct drm_atomic_state *state)struct drm_device *dev = state->dev;struct vc4_dev *vc4 =to_vc4_dev (dev); +vc4_hvs_mask_underrun (dev); +drm_atomic_helper_wait_for_fences (dev, state, false);drm_atomic_helper_wait_for_dependencies (state);
drivers/gpu/drm/vc4/vc4_kms.c vc4_atomic_complete_commit(struct drm_atomic_state *state) · line 164
Quoted 8 lines
drivers/gpu/drm/vc4/vc4_kms.c +2
-0@@ -155,6 +157,8 @@ vc4_atomic_complete_commit(struct drm_atomic_state *state)drm_atomic_helper_commit_hw_done (state); +vc4_hvs_unmask_underrun (dev); +drm_atomic_helper_wait_for_flip_done (dev, state);drm_atomic_helper_cleanup_planes (dev, state);
I think the mask/unmask in here could race against another atomic_commit happening on another CRTC in parallel. I guess maybe we should mask off interrupts on the specific channel being modified.
However, given that we're just talking about a debugfs entry and user-space testing tool, I'm fine with this as-is.
Other than my concern for patch #4, patch 1-3 are:
PATCH v4 2/4 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
@@ -312,6 +312,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
@@ -208,6 +208,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 *
@@ -383,6 +384,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 · 1 line
2.20.1
PATCH v4 3/4 drm/vc4: Detect and ignore underruns caused by out-of-sync dlists
In reply to Paul KocialkowskiWhen the pipeline is reconfigured with a different mode, changes take effect immediately for the CRTC and encoder while the HVS takes some time to switch the active display list. This results in a period of time where the pipeline is out of sync, that is very likely to cause an underrun to be reported. Because the underrun is not related to the new configuration, reporting it to userspace is a false positive.
Since this only concerns the first frame and we have no immediate fix to avoid this situation, detect and work around it.
A helper is introduced to return whether the enabled display channels have their display list in sync. This hint is set when unmasking the underrun interrupt and it is updated in the interrupt itself.
With that, underrun reports that happen when the display list is out of sync are ignored. The interrupt is kept enabled so that proper underrun indications can be pick up as soon as the new display list takes over.
--- drivers/gpu/drm/vc4/vc4_drv.h | 8 ++++++++ drivers/gpu/drm/vc4/vc4_hvs.c | 35 ++++++++++++++++++++++++++++++++-- drivers/gpu/drm/vc4/vc4_regs.h | 2 ++ 3 files changed, 43 insertions(+), 2 deletions(-)
drivers/gpu/drm/vc4/vc4_drv.h +8 -0
@@ -192,6 +192,13 @@ struct vc4_dev {*/ atomic_t underrun; +/* Stores whether the display lists were syncronized when unmasking the +* underrun IRQ. This is used to skip underruns reported when the +* pipeline was reconfigured but the previous display list is still +* active. +*/ +bool underrun_dlist_sync; +struct work_struct overflow_mem_work;int power_refcount;
@@ -792,6 +799,7 @@ 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); +bool vc4_hvs_check_dlist_sync (struct drm_device *dev);void vc4_hvs_unmask_underrun (struct drm_device *dev);void vc4_hvs_mask_underrun (struct drm_device *dev);
drivers/gpu/drm/vc4/vc4_hvs.c +33 -2
@@ -179,6 +179,23 @@ static int vc4_hvs_upload_linear_kernel(struct vc4_hvs *hvs,return 0 ; } +bool vc4_hvs_check_dlist_sync (struct drm_device *dev) +{ +struct vc4_dev *vc4 =to_vc4_dev (dev); +unsigned int i; + +for (i =0 ; i <SCALER_CHANNELS_COUNT ; i++) { +if (!(HVS_READ (SCALER_DISPCTRLX (i)) &SCALER_DISPCTRLX_ENABLE )) +continue ; + +if (HVS_READ (SCALER_DISPLACTX (i)) != +HVS_READ (SCALER_DISPLISTX (i))) +return false; + } + +return true; +} +void vc4_hvs_mask_underrun (struct drm_device *dev) {struct vc4_dev *vc4 =to_vc4_dev (dev);
@@ -196,6 +213,9 @@ void vc4_hvs_unmask_underrun(struct drm_device *dev)struct vc4_dev *vc4 =to_vc4_dev (dev);u32 dispctrl =HVS_READ (SCALER_DISPCTRL ); +/* An underrun will occur when the display lists are out of sync. */ + vc4->underrun_dlist_sync =vc4_hvs_check_dlist_sync (dev); + dispctrl |=SCALER_DISPCTRL_DSPEISLUR (0 ) |SCALER_DISPCTRL_DSPEISLUR (1 ) |SCALER_DISPCTRL_DSPEISLUR (2 );
@@ -220,19 +240,30 @@ static irqreturn_t vc4_hvs_irq_handler(int irq, void *data)struct drm_device *dev = data;struct vc4_dev *vc4 =to_vc4_dev (dev);irqreturn_t irqret =IRQ_NONE ; +bool dlist_sync;u32 status; + dlist_sync =vc4_hvs_check_dlist_sync (dev); status =HVS_READ (SCALER_DISPSTAT );if (status & (SCALER_DISPSTAT_EUFLOW (0 ) |SCALER_DISPSTAT_EUFLOW (1 ) |SCALER_DISPSTAT_EUFLOW (2 ))) { -vc4_hvs_mask_underrun (dev); -vc4_hvs_report_underrun (dev); +/* An underrun will be reported when the current display list +* was not yet updated by the hardware to the requested one and +* the other elements of the pipeline were already reconfigured. +* Ignore it in that case. +*/ +if (vc4->underrun_dlist_sync && dlist_sync) { +vc4_hvs_mask_underrun (dev); +vc4_hvs_report_underrun (dev); + } irqret =IRQ_HANDLED ; } + vc4->underrun_dlist_sync = dlist_sync; +HVS_WRITE (SCALER_DISPSTAT ,SCALER_DISPSTAT_IRQMASK (0 ) |SCALER_DISPSTAT_IRQMASK (1 ) |SCALER_DISPSTAT_IRQMASK (2 ));
drivers/gpu/drm/vc4/vc4_regs.h +2 -0
@@ -212,6 +212,8 @@#define PV_HACT_ACT 0x30 +#define SCALER_CHANNELS_COUNT 3 +#define SCALER_DISPCTRL 0x00000000/* Global register for clock gating the HVS */ # define SCALER_DISPCTRL_ENABLE BIT(31)
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v4 3/4] drm/vc4: Detect and ignore underruns caused by out-of-sync dlists
Quoted 6 lines · Paul Kocialkowski
When the pipeline is reconfigured with a different mode, changes take effect immediately for the CRTC and encoder while the HVS takes some time to switch the active display list. This results in a period of time where the pipeline is out of sync, that is very likely to cause an underrun to be reported. Because the underrun is not related to the new configuration, reporting it to userspace is a false positive.
This seems like a serious issue. How are we enabling a CRTC with the corresponding HVS still scanning out old contents? Did we need to wait for HVS to finish its old frame when we turned off the CRTC, so it's ready to receive the START when it's been set up with the new dlist and the CRTC is turned back on? Or maybe do some sort of reset of that dlist when a crtc is being enabled?
If we can't sort that out, it feels to me like we should be enabling the interrupts from the flip_done path (when we know that the HVS is scanning out the new frame) instead of trying to mitigate enabling them too early.
Re: [PATCH v4 3/4] drm/vc4: Detect and ignore underruns caused by out-of-sync dlists
Hi,
Quoted 9 lines · Eric Anholt
Quoted 6 lines · Paul Kocialkowski
When the pipeline is reconfigured with a different mode, changes take effect immediately for the CRTC and encoder while the HVS takes some time to switch the active display list. This results in a period of time where the pipeline is out of sync, that is very likely to cause an underrun to be reported. Because the underrun is not related to the new configuration, reporting it to userspace is a false positive.
Quoted 6 lines
This seems like a serious issue. How are we enabling a CRTC with the corresponding HVS still scanning out old contents? Did we need to wait for HVS to finish its old frame when we turned off the CRTC, so it's ready to receive the START when it's been set up with the new dlist and the CRTC is turned back on? Or maybe do some sort of reset of that dlist when a crtc is being enabled?
Yes this has definitely been quite a burden. I have already tried waiting for the end of frame before disabling the crtc, as well as playing with various other bits and FIFO reset (see the "HDMI mode reconfiguration issue mitigation" thread). Alas, nothing helped and I moved on to implementing a workaround after you said not to block on this particular point.
Quoted 4 lines
If we can't sort that out, it feels to me like we should be enabling the interrupts from the
flip_donepath (when we know that the HVS is scanning out the new frame) instead of trying to mitigate enabling them too early.
Thanks for the hint! I looked into this solution and it seems viable, although I found out that interrupt masking is not always honored by the hardware. With some extra care, it seems to be working reliably.
I'll send a new iteration implementing the workaround this way.
Cheers,
Paul
Signature · 3 lines
Paul Kocialkowski, Bootlin Embedded Linux and kernel engineering https://bootlin.com
PATCH v4 4/4 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
@@ -203,6 +203,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
@@ -433,6 +433,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. */
@@ -505,6 +509,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 · 1 line
2.20.1