mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 13:48:06 +02:00
panfrost: avoid potential divide by 0 calculating timer_resolution
On armhf integer divide by 0 can raise SIGFPE, whereas on aarch64 it just returns 0. This has become an issue because the recently added panfrost_init_screen_caps always calls pan_gpu_time_to_ns to calculate caps->timer_resolution, whereas before we only called it when PIPE_CAP_TIMER_RESOLUTION was queried, and only OpenCL does that (and not always). Fixes:205669e3a9("panfrost: add panfrost_init_screen_caps") Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33435> (cherry picked from commite550a3cab0)
This commit is contained in:
parent
4736448bde
commit
eabe6ec941
3 changed files with 4 additions and 2 deletions
|
|
@ -554,7 +554,7 @@
|
|||
"description": "panfrost: avoid potential divide by 0 calculating timer_resolution",
|
||||
"nominated": true,
|
||||
"nomination_type": 2,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "205669e3a93a373fee2f4d0c8994b62c9faa371f",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -229,6 +229,7 @@ pan_is_bifrost(const struct panfrost_device *dev)
|
|||
static inline uint64_t
|
||||
pan_gpu_time_to_ns(struct panfrost_device *dev, uint64_t gpu_time)
|
||||
{
|
||||
assert(dev->kmod.props.timestamp_frequency > 0);
|
||||
return (gpu_time * NSEC_PER_SEC) / dev->kmod.props.timestamp_frequency;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -668,7 +668,8 @@ panfrost_init_screen_caps(struct panfrost_screen *screen)
|
|||
dev->kmod.props.gpu_can_query_timestamp &&
|
||||
dev->kmod.props.timestamp_frequency != 0;
|
||||
|
||||
caps->timer_resolution = pan_gpu_time_to_ns(dev, 1);
|
||||
if (caps->query_timestamp)
|
||||
caps->timer_resolution = pan_gpu_time_to_ns(dev, 1);
|
||||
|
||||
/* The hardware requires element alignment for data conversion to work
|
||||
* as expected. If data conversion is not required, this restriction is
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue