[PATCH v1] ImgTec powerVR DRM driver: Convert to use time_before macro
Matt Coster
Matt.Coster at imgtec.com
Thu Aug 22 11:41:56 UTC 2024
Hi Chen,
Thanks for the patch! Just a couple minor notes.
On 21/08/2024 10:21, Chen Yufan wrote:
> 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:".
> 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.
> Signed-off-by: Chen Yufan <chenyufan at vivo.com>
Please add a Fixes: tag as per [1].
> ---
> drivers/gpu/drm/imagination/pvr_ccb.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/imagination/pvr_ccb.c b/drivers/gpu/drm/imagination/pvr_ccb.c
> index 4deeac7ed..b7d5f9ca3 100644
> --- a/drivers/gpu/drm/imagination/pvr_ccb.c
> +++ b/drivers/gpu/drm/imagination/pvr_ccb.c
> @@ -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
> retries < RESERVE_SLOT_MIN_RETRIES) {
> reserved = pvr_kccb_try_reserve_slot(pvr_dev);
> if (reserved)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 236 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20240822/acfaf72a/attachment-0001.sig>
More information about the dri-devel
mailing list