Skip to contentSkip to conversation

drm/vc4: 3 minor fixes from mismatched drm_dev_[enter|exit] calls

PATCH Applied Dave Stevenson 3 participants 12 messages Oct 8, 2024 – Oct 9, 2024

Subsystems (3)
lore
Share & tools
lore

Dave Stevenson

author maintainer
#0 lore raw

cover 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]>
author maintainer
#1 lore raw

PATCH 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.

Fixes 52efe364d196 ("drm/vc4: hvs: Don't write gamma luts on 2711")
---
 drivers/gpu/drm/vc4/vc4_hvs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hvs.c +2 -1
index 2a366a607fcc..546ee11016b2 100644
@@ -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
reviewer Reviewed-by on v1 1/3
#2 lore raw

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 to vc4_hvs_lut_load that had called drm_dev_enter, but not drm_dev_exit.

Ensure we call drm_dev_exit.

Fixes 52efe364d196 ("drm/vc4: hvs: Don't write gamma luts on 2711")
---
  drivers/gpu/drm/vc4/vc4_hvs.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hvs.c +0 -0
index 2a366a607fcc..546ee11016b2 100644

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);
  }
 
Tested-by on v1 1/3
#3 lore raw

Re: [PATCH 1/3] drm/vc4: Match drm_dev_enter and exit calls in vc4_hvs_lut_load

In reply to Dave Stevenson
Quoted 10 lines · Dave Stevenson

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.

Fixes 52efe364d196 ("drm/vc4: hvs: Don't write gamma luts on 2711")
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
index 2a366a607fcc..546ee11016b2 100644
@@ -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
author maintainer
#4 lore raw

PATCH 2/3 drm/vc4: Match drm_dev_enter and exit calls in vc4_hvs_atomic_flush

In reply to Dave Stevenson

Commit 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.

Fixes 92c17d16476c ("drm/vc4: hvs: Ignore atomic_flush if we're disabled")
---
 drivers/gpu/drm/vc4/vc4_hvs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hvs.c +2 -1
index 546ee11016b2..c5ebc317188a 100644
@@ -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
reviewer Reviewed-by on v1 2/3
#5 lore raw

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: 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.

Fixes 92c17d16476c ("drm/vc4: hvs: Ignore atomic_flush if we're disabled")

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
index 546ee11016b2..c5ebc317188a 100644
@@ -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);
  }
 
Tested-by on v1 2/3
#6 lore raw

Re: [PATCH 2/3] drm/vc4: Match drm_dev_enter and exit calls in vc4_hvs_atomic_flush

In reply to Dave Stevenson
Quoted 7 lines · Dave Stevenson

Commit 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.

Fixes 92c17d16476c ("drm/vc4: hvs: Ignore atomic_flush if we're disabled")
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
index 546ee11016b2..c5ebc317188a 100644
@@ -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
author maintainer
#7 lore raw

PATCH 3/3 drm/vc4: Correct generation check in vc4_hvs_lut_load

In reply to Dave Stevenson

Commit 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.

Fixes 24c5ed3ddf27 ("drm/vc4: Introduce generation number enum")
---
 drivers/gpu/drm/vc4/vc4_hvs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hvs.c +1 -1
index c5ebc317188a..1edf6e3fa7e6 100644
@@ -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
reviewer Reviewed-by on v1 3/3
#8 lore raw

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 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.

Fixes 24c5ed3ddf27 ("drm/vc4: Introduce generation number enum")
---
  drivers/gpu/drm/vc4/vc4_hvs.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hvs.c +0 -0
index c5ebc317188a..1edf6e3fa7e6 100644

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 -0
  		goto exit;
 
  	/* The LUT memory is laid out with each HVS channel in order,
author maintainer
#9 lore raw

Re: [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 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.

Fixes 24c5ed3ddf27 ("drm/vc4: Introduce generation number enum")
---
  drivers/gpu/drm/vc4/vc4_hvs.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hvs.c +0 -0
index c5ebc317188a..1edf6e3fa7e6 100644
@@ -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_4 is 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:

Best Regards,
- Maíra

Quoted 4 lines
drivers/gpu/drm/vc4/vc4_hvs.c +0 -0
              goto exit;
 
      /* The LUT memory is laid out with each HVS channel in order,
Tested-by on v1 3/3
#10 lore raw

Re: [PATCH 3/3] drm/vc4: Correct generation check in vc4_hvs_lut_load

In reply to Dave Stevenson
Quoted 9 lines · Dave Stevenson

Commit 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.

Fixes 24c5ed3ddf27 ("drm/vc4: Introduce generation number enum")
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
index c5ebc317188a..1edf6e3fa7e6 100644

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
author maintainer Applied
#11 lore raw
In reply to Dave Stevenson
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 calling drm_dev_exit.

Applied to drm-misc-next.

Quoted 16 lines

---
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,
--
Dave Stevenson <[email protected]>