Skip to contentSkip to conversation

ImgTec powerVR DRM driver: Convert to use time_before macro

PATCH Superseded Chen Yufan 2 participants 2 messages Aug 21, 2024 – Aug 22, 2024

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Chen Yufan

author
#0 lore raw

PATCH 1/1 ImgTec powerVR DRM driver: Convert to use time_before macro

Use time_before instead of direct subtraction for readability.

---
 drivers/gpu/drm/imagination/pvr_ccb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/imagination/pvr_ccb.c +1 -1
index 4deeac7ed..b7d5f9ca3 100644
@@ -321,7 +321,7 @@ static int pvr_kccb_reserve_slot_sync(struct pvr_device *pvr_dev)
 	bool reserved = false;
 	u32 retries = 0;
 
-	while ((jiffies - start_timestamp) < (u32)RESERVE_SLOT_TIMEOUT ||
+	while (time_before(jiffies, start_timestamp + (u32)RESERVE_SLOT_TIMEOUT) ||
 	       retries < RESERVE_SLOT_MIN_RETRIES) {
 		reserved = pvr_kccb_try_reserve_slot(pvr_dev);
 		if (reserved)
Signature · 1 line
2.39.0
#1 lore raw

Hi Chen,

Thanks for the patch! Just a couple minor notes.

Quoted 1 line · Chen Yufan

Subject: [PATCH v1] ImgTec powerVR DRM driver: Convert to use time_before macro

The prefix here should be based on the source path. For us, that's "drm/imagination:".

Quoted 1 line

Use time_before instead of direct subtraction for readability.

I think the real justification here is correctness. The code as it currently exists is susceptible to overflow issues that are handled correctly by the time_*() macros.

Quoted 1 line

Please add a Fixes: tag as per [1].

Quoted 9 lines
---
  drivers/gpu/drm/imagination/pvr_ccb.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/imagination/pvr_ccb.c +0 -0
index 4deeac7ed..b7d5f9ca3 100644

drivers/gpu/drm/imagination/pvr_ccb.c static int pvr_kccb_reserve_slot_sync(struct pvr_device *pvr_dev) · line 324

Quoted 5 lines
drivers/gpu/drm/imagination/pvr_ccb.c +1 -1
@@ -321,7 +321,7 @@ static int pvr_kccb_reserve_slot_sync(struct pvr_device *pvr_dev)
  	bool reserved = false;
  	u32 retries = 0;
 
-	while ((jiffies - start_timestamp) < (u32)RESERVE_SLOT_TIMEOUT ||
+	while (time_before(jiffies, start_timestamp + (u32)RESERVE_SLOT_TIMEOUT) ||

You might as well drop the cast here too; it only seems to have existed here as an attempt to correclty deal with overflow.

Cheers,
Matt

[1]: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes

Quoted 3 lines
drivers/gpu/drm/imagination/pvr_ccb.c +0 -0
  	       retries < RESERVE_SLOT_MIN_RETRIES) {
  		reserved = pvr_kccb_try_reserve_slot(pvr_dev);
  		if (reserved)