Module: Mesa Branch: staging/22.2 Commit: 842011a4bdf9c996f33a5d77254c22c1ebe889d7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=842011a4bdf9c996f33a5d77254c22c1ebe889d7
Author: Mark Collins <[email protected]> Date: Fri Sep 2 10:09:11 2022 +0000 tu: Clamp priority in DRM submitqueue creation The kernel driver has a range of valid priority values that can be supplied to it, submitting any priority value outside these bounds will result in `-EINVAL`. To avoid this, the priority value is now clamped to the range that the kernel supports. Fixes: 0c6fbfca0c91ef012e8ab767a317c07f1f6dc5e6 Signed-off-by: Mark Collins <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18389> (cherry picked from commit c82249aa6891e43398cc8d62d552869495292b31) --- .pick_status.json | 2 +- src/freedreno/vulkan/tu_drm.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 2b8403ca7eb..e76e69bc17a 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -3253,7 +3253,7 @@ "description": "tu: Clamp priority in DRM submitqueue creation", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "0c6fbfca0c91ef012e8ab767a317c07f1f6dc5e6" }, diff --git a/src/freedreno/vulkan/tu_drm.c b/src/freedreno/vulkan/tu_drm.c index d00fdd0f9bc..42e192355cf 100644 --- a/src/freedreno/vulkan/tu_drm.c +++ b/src/freedreno/vulkan/tu_drm.c @@ -144,9 +144,12 @@ tu_drm_submitqueue_new(const struct tu_device *dev, int priority, uint32_t *queue_id) { + uint64_t nr_rings = 1; + tu_drm_get_param(dev->physical_device, MSM_PARAM_NR_RINGS, &nr_rings); + struct drm_msm_submitqueue req = { .flags = 0, - .prio = priority, + .prio = MIN2(priority, MAX2(nr_rings, 1) - 1), }; int ret = drmCommandWriteRead(dev->fd,
