From: Andi Shyti <andi.shyti@linux.intel.com>
To: fei.yang@intel.com
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [Intel-xe] [PATCH 1/1] drm/xe: timeout needs to be a signed value
Date: Fri, 22 Sep 2023 15:18:42 +0200 [thread overview]
Message-ID: <ZQ2UMrrVMmSRHovd@ashyti-mobl2.lan> (raw)
In-Reply-To: <20230921220500.994558-2-fei.yang@intel.com>
Hi Fei,
[...]
> -static unsigned long to_jiffies_timeout(struct drm_xe_wait_user_fence *args)
> +static long to_jiffies_timeout(struct xe_device *xe,
> + struct drm_xe_wait_user_fence *args)
> {
> - unsigned long timeout;
> + unsigned long long t;
> + long timeout;
>
> - if (args->flags & DRM_XE_UFENCE_WAIT_ABSTIME)
> - return drm_timeout_abs_to_jiffies(args->timeout);
> + /*
> + * For negative timeout we want to wait "forever" by setting
> + * MAX_SCHEDULE_TIMEOUT. But we have to assign this value also
> + * to args->timeout to avoid being zeroed on the signal delivery
> + * (see arithmetics after wait).
> + */
> + if (args->timeout < 0) {
> + args->timeout = MAX_SCHEDULE_TIMEOUT;
> + return MAX_SCHEDULE_TIMEOUT;
> + }
>
> - if (args->timeout == MAX_SCHEDULE_TIMEOUT || args->timeout == 0)
> - return args->timeout;
> + if (args->timeout == 0)
> + return 0;
>
> - timeout = nsecs_to_jiffies(args->timeout);
> + /*
> + * Save the timeout to an u64 variable because nsecs_to_jiffies
> + * might return a value that overflows s32 variable.
> + */
> + if (args->flags & DRM_XE_UFENCE_WAIT_ABSTIME)
> + t = drm_timeout_abs_to_jiffies(args->timeout);
> + else
> + t = nsecs_to_jiffies(args->timeout);
> +
> + /*
> + * Anything greater then MAX_SCHEDULE_TIMEOUT is meaningless,
> + * also we don't want to cap it at MAX_SCHEDULE_TIMEOUT because
> + * apparently user doesn't mean to wait forever, otherwise the
> + * args->timeout should have been set to a negative value.
> + */
> + if (t > MAX_SCHEDULE_TIMEOUT)
> + timeout = MAX_SCHEDULE_TIMEOUT - 1;
> + else
> + timeout = t;
you found some boundary case here... thanks!
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Andi
next prev parent reply other threads:[~2023-09-22 13:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-21 22:04 [Intel-xe] [PATCH 0/1] drm/xe: timeout needs to be a signed value fei.yang
2023-09-21 22:05 ` [Intel-xe] [PATCH 1/1] " fei.yang
2023-09-22 13:18 ` Andi Shyti [this message]
2023-09-21 22:41 ` [Intel-xe] ✓ CI.Patch_applied: success for " Patchwork
2023-09-21 22:41 ` [Intel-xe] ✗ CI.checkpatch: warning " Patchwork
2023-09-21 22:42 ` [Intel-xe] ✓ CI.KUnit: success " Patchwork
2023-09-21 22:49 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-09-21 22:50 ` [Intel-xe] ✓ CI.Hooks: " Patchwork
2023-09-21 22:51 ` [Intel-xe] ✓ CI.checksparse: " Patchwork
2023-09-21 23:26 ` [Intel-xe] ✓ CI.BAT: " Patchwork
2023-09-29 6:04 ` [Intel-xe] [PATCH 0/1] " Lucas De Marchi
-- strict thread matches above, loose matches on Subject: below --
2023-09-26 4:12 fei.yang
2023-09-26 4:12 ` [Intel-xe] [PATCH 1/1] " fei.yang
2023-09-26 8:25 ` Upadhyay, Tejas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZQ2UMrrVMmSRHovd@ashyti-mobl2.lan \
--to=andi.shyti@linux.intel.com \
--cc=fei.yang@intel.com \
--cc=intel-xe@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox