drm/vc4: 3 minor fixes from mismatched drm_dev_[enter|exit] calls
Subsystems (3)
Dave Stevenson
maintainercover drm/vc4: 3 minor fixes from mismatched drm_dev_[enter|exit] calls
These are 3 fixes noted from Marek's report that he was seeing lock held issues.
The place he had noticed was actually triggered due to an incorrect change to a conditional, but also a further place was noted where it was possible to leave the function without calling drm_dev_exit.
---
Dave Stevenson (3):
drm/vc4: Match drm_dev_enter and exit calls in vc4_hvs_lut_load drm/vc4: Match drm_dev_enter and exit calls in vc4_hvs_atomic_flush drm/vc4: Correct generation check in vc4_hvs_lut_load
drivers/gpu/drm/vc4/vc4_hvs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
---
base-commit: 2c34a5464007c45142af009d13c668b0630ef9c0
change-id: 20241008-drm-vc4-fixes-4aceb259455c
Best regards,
Signature · 1 line
Dave Stevenson <[email protected]>
Dave Stevenson
maintainerPATCH 1/3 drm/vc4: Match drm_dev_enter and exit calls in vc4_hvs_lut_load
Commit 52efe364d196 ("drm/vc4: hvs: Don't write gamma luts on 2711") added a return path to vc4_hvs_lut_load that had called drm_dev_enter, but not drm_dev_exit.
Ensure we call drm_dev_exit.
--- drivers/gpu/drm/vc4/vc4_hvs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hvs.c +2 -1
@@ -225,7 +225,7 @@ static void vc4_hvs_lut_load(struct vc4_hvs *hvs,return ;if (hvs->vc4->gen ==VC4_GEN_4 ) -return ; + goto exit;/* The LUT memory is laid out with each HVS channel in order, * each of which takes 256 writes for R, 256 for G, then 256
@@ -242,6 +242,7 @@ static void vc4_hvs_lut_load(struct vc4_hvs *hvs,for (i =0 ; i < crtc->gamma_size; i++)HVS_WRITE (SCALER_GAMDATA , vc4_crtc->lut_b[i]); +exit:drm_dev_exit (idx); }
Signature · 1 line
2.34.1
Re: [PATCH 1/3] drm/vc4: Match drm_dev_enter and exit calls in vc4_hvs_lut_load
Hi Dave,
Quoted 19 lines · Dave Stevenson
Commit
52efe364d196("drm/vc4: hvs: Don't write gamma luts on 2711") added a return path tovc4_hvs_lut_loadthat had calleddrm_dev_enter, but notdrm_dev_exit.Ensure we call
drm_dev_exit.Fixes 52efe364d196 ("drm/vc4: hvs: Don't write gamma luts on 2711")Reported-by Marek Szyprowski <[email protected]>Signed-off-by Dave Stevenson <[email protected]>--- drivers/gpu/drm/vc4/vc4_hvs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_hvs.c +0
-0
drivers/gpu/drm/vc4/vc4_hvs.c static void vc4_hvs_lut_load(struct vc4_hvs *hvs, · line 228
Quoted 5 lines
drivers/gpu/drm/vc4/vc4_hvs.c +1
-1@@ -225,7 +225,7 @@ static void vc4_hvs_lut_load(struct vc4_hvs *hvs,return ;if (hvs->vc4->gen ==VC4_GEN_4 ) -return ; + goto exit;
As exit only has one function, I'd probably switch return; to return drm_dev_exit(idx); as drm_dev_exit() returns void.
But this isn't critical, so:
Best Regards,
- Maíra
Quoted 12 lines
drivers/gpu/drm/vc4/vc4_hvs.c +1
-0/* The LUT memory is laid out with each HVS channel in order, * each of which takes 256 writes for R, 256 for G, then 256 @@ -242,6 +242,7 @@ static void vc4_hvs_lut_load(struct vc4_hvs *hvs,for (i =0 ; i < crtc->gamma_size; i++)HVS_WRITE (SCALER_GAMDATA , vc4_crtc->lut_b[i]); +exit:drm_dev_exit (idx); }
Re: [PATCH 1/3] drm/vc4: Match drm_dev_enter and exit calls in vc4_hvs_lut_load
In reply to Dave StevensonQuoted 10 lines · Dave Stevenson
Commit
52efe364d196("drm/vc4: hvs: Don't write gamma luts on 2711") added a return path tovc4_hvs_lut_loadthat had calleddrm_dev_enter, but notdrm_dev_exit.Ensure we call
drm_dev_exit.Fixes 52efe364d196 ("drm/vc4: hvs: Don't write gamma luts on 2711")Reported-by Marek Szyprowski <[email protected]>Signed-off-by Dave Stevenson <[email protected]>
Quoted 19 lines
--- drivers/gpu/drm/vc4/vc4_hvs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_hvs.c +1
-1@@ -225,7 +225,7 @@ static void vc4_hvs_lut_load(struct vc4_hvs *hvs,return ;if (hvs->vc4->gen ==VC4_GEN_4 ) -return ; + goto exit;/* The LUT memory is laid out with each HVS channel in order, * each of which takes 256 writes for R, 256 for G, then 256
drivers/gpu/drm/vc4/vc4_hvs.c static void vc4_hvs_lut_load(struct vc4_hvs *hvs, · line 248
Quoted 7 lines
drivers/gpu/drm/vc4/vc4_hvs.c +1
-0@@ -242,6 +242,7 @@ static void vc4_hvs_lut_load(struct vc4_hvs *hvs,for (i =0 ; i < crtc->gamma_size; i++)HVS_WRITE (SCALER_GAMDATA , vc4_crtc->lut_b[i]); +exit:drm_dev_exit (idx); }
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
Dave Stevenson
maintainerPATCH 2/3 drm/vc4: Match drm_dev_enter and exit calls in vc4_hvs_atomic_flush
In reply to Dave StevensonCommit 92c17d16476c ("drm/vc4: hvs: Ignore atomic_flush if we're disabled") added a path which returned early without having called drm_dev_exit.
Ensure all paths call drm_dev_exit.
--- drivers/gpu/drm/vc4/vc4_hvs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hvs.c +2 -1
@@ -603,7 +603,7 @@ void vc4_hvs_atomic_flush(struct drm_crtc *crtc, }if (vc4_state->assigned_channel ==VC4_HVS_CHANNEL_DISABLED ) -return ; + goto exit;if (debug_dump_regs) {DRM_INFO ("CRTC %d HVS before:\n" ,drm_crtc_index (crtc));
@@ -686,6 +686,7 @@ void vc4_hvs_atomic_flush(struct drm_crtc *crtc,vc4_hvs_dump_state (hvs); } +exit:drm_dev_exit (idx); }
Signature · 1 line
2.34.1
Re: [PATCH 2/3] drm/vc4: Match drm_dev_enter and exit calls in vc4_hvs_atomic_flush
Hi Dave,
Quoted 7 lines · Dave Stevenson
Commit
92c17d16476c("drm/vc4: hvs: Ignoreatomic_flushif we're disabled") added a path which returned early without having calleddrm_dev_exit.Ensure all paths call
drm_dev_exit.Fixes 92c17d16476c ("drm/vc4: hvs: Ignore atomic_flush if we're disabled")Signed-off-by Dave Stevenson <[email protected]>
With the same comment as PATCH 1/3,
Best Regards,
- Maíra
Quoted 26 lines
--- drivers/gpu/drm/vc4/vc4_hvs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_hvs.c +2
-1@@ -603,7 +603,7 @@ void vc4_hvs_atomic_flush(struct drm_crtc *crtc, }if (vc4_state->assigned_channel ==VC4_HVS_CHANNEL_DISABLED ) -return ; + goto exit;if (debug_dump_regs) {DRM_INFO ("CRTC %d HVS before:\n" ,drm_crtc_index (crtc));@@ -686,6 +686,7 @@ void vc4_hvs_atomic_flush(struct drm_crtc *crtc,vc4_hvs_dump_state (hvs); } +exit:drm_dev_exit (idx); }
Re: [PATCH 2/3] drm/vc4: Match drm_dev_enter and exit calls in vc4_hvs_atomic_flush
In reply to Dave StevensonQuoted 7 lines · Dave Stevenson
Commit
92c17d16476c("drm/vc4: hvs: Ignoreatomic_flushif we're disabled") added a path which returned early without having calleddrm_dev_exit.Ensure all paths call
drm_dev_exit.Fixes 92c17d16476c ("drm/vc4: hvs: Ignore atomic_flush if we're disabled")Signed-off-by Dave Stevenson <[email protected]>
Quoted 19 lines
--- drivers/gpu/drm/vc4/vc4_hvs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_hvs.c +1
-1@@ -603,7 +603,7 @@ void vc4_hvs_atomic_flush(struct drm_crtc *crtc, }if (vc4_state->assigned_channel ==VC4_HVS_CHANNEL_DISABLED ) -return ; + goto exit;if (debug_dump_regs) {DRM_INFO ("CRTC %d HVS before:\n" ,drm_crtc_index (crtc));
drivers/gpu/drm/vc4/vc4_hvs.c void vc4_hvs_atomic_flush(struct drm_crtc *crtc, · line 692
Quoted 7 lines
drivers/gpu/drm/vc4/vc4_hvs.c +1
-0@@ -686,6 +686,7 @@ void vc4_hvs_atomic_flush(struct drm_crtc *crtc,vc4_hvs_dump_state (hvs); } +exit:drm_dev_exit (idx); }
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
Dave Stevenson
maintainerPATCH 3/3 drm/vc4: Correct generation check in vc4_hvs_lut_load
In reply to Dave StevensonCommit 24c5ed3ddf27 ("drm/vc4: Introduce generation number enum") incorrectly swapped a check of hvs->vc4->is_vc5 to hvs->vc4->gen == VC4_GEN_4 in vc4_hvs_lut_load, hence breaking loading the gamma look up table on Pi0-3.
Correct that conditional.
--- drivers/gpu/drm/vc4/vc4_hvs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hvs.c +1 -1
@@ -224,7 +224,7 @@ static void vc4_hvs_lut_load(struct vc4_hvs *hvs,if (!drm_dev_enter (drm, &idx))return ; -if (hvs->vc4->gen ==VC4_GEN_4 ) +if (hvs->vc4->gen !=VC4_GEN_4 ) goto exit;/* The LUT memory is laid out with each HVS channel in order,
Signature · 1 line
2.34.1
Re: [PATCH 3/3] drm/vc4: Correct generation check in vc4_hvs_lut_load
Hi Dave,
Quoted 18 lines · Dave Stevenson
Commit
24c5ed3ddf27("drm/vc4: Introduce generation number enum") incorrectly swapped a check ofhvs->vc4->is_vc5tohvs->vc4->gen==VC4_GEN_4invc4_hvs_lut_load, hence breaking loading the gamma look up table on Pi0-3.Correct that conditional.
Fixes 24c5ed3ddf27 ("drm/vc4: Introduce generation number enum")Signed-off-by Dave Stevenson <[email protected]>--- drivers/gpu/drm/vc4/vc4_hvs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_hvs.c +0
-0
drivers/gpu/drm/vc4/vc4_hvs.c static void vc4_hvs_lut_load(struct vc4_hvs *hvs, · line 227
Quoted 5 lines
drivers/gpu/drm/vc4/vc4_hvs.c +1
-1@@ -224,7 +224,7 @@ static void vc4_hvs_lut_load(struct vc4_hvs *hvs,if (!drm_dev_enter (drm, &idx))return ; -if (hvs->vc4->gen ==VC4_GEN_4 ) +if (hvs->vc4->gen !=VC4_GEN_4 )
Again, another nit: I believe hvs->vc4->gen > VC4_GEN_4 is more semantic and it's the standard I usually see around the driver.
But this isn't critical, so:
Best Regards,
- Maíra
Quoted 4 lines
drivers/gpu/drm/vc4/vc4_hvs.c +0
-0goto exit;/* The LUT memory is laid out with each HVS channel in order,
Dave Stevenson
maintainerRe: [PATCH 3/3] drm/vc4: Correct generation check in vc4_hvs_lut_load
Hi Maira
Thanks for the review
Quoted 25 lines · Maíra Canal
Hi Dave,
Quoted 21 lines · Dave Stevenson
Commit
24c5ed3ddf27("drm/vc4: Introduce generation number enum") incorrectly swapped a check ofhvs->vc4->is_vc5tohvs->vc4->gen==VC4_GEN_4invc4_hvs_lut_load, hence breaking loading the gamma look up table on Pi0-3.Correct that conditional.
Fixes 24c5ed3ddf27 ("drm/vc4: Introduce generation number enum")Signed-off-by Dave Stevenson <[email protected]>--- drivers/gpu/drm/vc4/vc4_hvs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_hvs.c +0
-0@@ -224,7 +224,7 @@ static void vc4_hvs_lut_load(struct vc4_hvs *hvs,if (!drm_dev_enter (drm, &idx))return ;
Quoted 5 lines
drivers/gpu/drm/vc4/vc4_hvs.c static void vc4_hvs_lut_load(struct vc4_hvs *hvs, · line 227
Quoted 2 lines
drivers/gpu/drm/vc4/vc4_hvs.c +1
-1-if (hvs->vc4->gen ==VC4_GEN_4 ) +if (hvs->vc4->gen !=VC4_GEN_4 )Again, another nit: I believe
hvs->vc4->gen > VC4_GEN_4is more semantic and it's the standard I usually see around the driver.
With 24c5ed3ddf27 which this is fixing, all instances in vc4_hvs.c were changed to == VC4_GEN_4 or == VC4_GEN_5. So I guess == VC4_GEN_5 would have been the better option here.
Yes downstream we now have GEN_6 (which I'm nearly at a point to send to the list), and I'll need to update this conditional when that's added.
I'll leave it as is for now, and ensure I've done an audit of all of them before pushing GEN_6.
Thanks
Dave
Quoted 11 lines
But this isn't critical, so:
Reviewed-by Maíra Canal <[email protected]>Best Regards,
- MaíraQuoted 4 lines
drivers/gpu/drm/vc4/vc4_hvs.c +0
-0goto exit;/* The LUT memory is laid out with each HVS channel in order,
Re: [PATCH 3/3] drm/vc4: Correct generation check in vc4_hvs_lut_load
In reply to Dave StevensonQuoted 9 lines · Dave Stevenson
Commit
24c5ed3ddf27("drm/vc4: Introduce generation number enum") incorrectly swapped a check ofhvs->vc4->is_vc5tohvs->vc4->gen==VC4_GEN_4invc4_hvs_lut_load, hence breaking loading the gamma look up table on Pi0-3.Correct that conditional.
Fixes 24c5ed3ddf27 ("drm/vc4: Introduce generation number enum")Signed-off-by Dave Stevenson <[email protected]>
Quoted 10 lines
--- drivers/gpu/drm/vc4/vc4_hvs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_hvs.c +0
-0
drivers/gpu/drm/vc4/vc4_hvs.c static void vc4_hvs_lut_load(struct vc4_hvs *hvs, · line 230
Quoted 8 lines
drivers/gpu/drm/vc4/vc4_hvs.c +1
-1@@ -224,7 +224,7 @@ static void vc4_hvs_lut_load(struct vc4_hvs *hvs,if (!drm_dev_enter (drm, &idx))return ; -if (hvs->vc4->gen ==VC4_GEN_4 ) +if (hvs->vc4->gen !=VC4_GEN_4 ) goto exit;/* The LUT memory is laid out with each HVS channel in order,
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
Quoted 8 lines · Dave Stevenson
These are 3 fixes noted from Marek's report that he was seeing lock held issues.
The place he had noticed was actually triggered due to an incorrect change to a conditional, but also a further place was noted where it was possible to leave the function without callingdrm_dev_exit.Signed-off-by Dave Stevenson <[email protected]>
Applied to drm-misc-next.
Quoted 16 lines
---
Dave Stevenson (3):
drm/vc4: Matchdrm_dev_enterand exit calls invc4_hvs_lut_loaddrm/vc4: Matchdrm_dev_enterand exit calls invc4_hvs_atomic_flushdrm/vc4: Correct generation check invc4_hvs_lut_loaddrivers/gpu/drm/vc4/vc4_hvs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)---
base-commit:2c34a5464007c45142af009d13c668b0630ef9c0
change-id: 20241008-drm-vc4-fixes-4aceb259455cBest regards,
--
Dave Stevenson <[email protected]>