diff options
author | Rob Clark <robclark@freedesktop.org> | 2018-01-24 15:08:46 -0500 |
---|---|---|
committer | Rob Clark <robclark@freedesktop.org> | 2018-01-26 15:29:10 -0500 |
commit | 6f0f6cee5e9be1dcf816c144e05d26352c85a9e8 (patch) | |
tree | 8326e8b234c44da67b35444a4f4977f0d84b66cd /freedreno/msm | |
parent | 82aef5f0cbeb5145408f8c5979dc826937d51b7b (diff) | |
download | libdrm-6f0f6cee5e9be1dcf816c144e05d26352c85a9e8.tar.gz libdrm-6f0f6cee5e9be1dcf816c144e05d26352c85a9e8.tar.bz2 libdrm-6f0f6cee5e9be1dcf816c144e05d26352c85a9e8.zip |
freedreno: clamp priority based on # of rings
In case of a kernel that is new enough to support multiple submit-
queues, but with an adreno generation which doesn't support multiple
prioritized ringbuffers, we'd attempt to open a submit-queue with
prio=1 (medium), which is rejected by the kernel.
This could happen either w/ an older mesa (which uses fd_pipe_new())
or a newer mesa which defaults to prio=1 if no pipe context priority
flags are set.
The simple answer to fix both cases is to clamp the requested priority
according to the number of rings. This might not do exactly what you
want, if we hypothetically had 2 rings (it would result in requested
medium priority being high priority instead of low priority). But the
number of rings (for hw gen's that support this) is purely a software
construct, so the easy answer there is to have the kernel advertise at
least 3 rings if it supports more than one. There isn't really any
reason to do otherwise.
Signed-off-by: Rob Clark <robclark@freedesktop.org>
Diffstat (limited to 'freedreno/msm')
-rw-r--r-- | freedreno/msm/msm_pipe.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/freedreno/msm/msm_pipe.c b/freedreno/msm/msm_pipe.c index 7395e573..12e4be59 100644 --- a/freedreno/msm/msm_pipe.c +++ b/freedreno/msm/msm_pipe.c @@ -100,42 +100,48 @@ static int msm_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp, return 0; } -static int open_submitqueue(struct fd_device *dev, uint32_t prio, - uint32_t *queue_id) +static int open_submitqueue(struct fd_pipe *pipe, uint32_t prio) { struct drm_msm_submitqueue req = { .flags = 0, .prio = prio, }; + uint64_t nr_rings = 1; int ret; - if (fd_device_version(dev) < FD_VERSION_SUBMIT_QUEUES) { - *queue_id = 0; + if (fd_device_version(pipe->dev) < FD_VERSION_SUBMIT_QUEUES) { + to_msm_pipe(pipe)->queue_id = 0; return 0; } - ret = drmCommandWriteRead(dev->fd, DRM_MSM_SUBMITQUEUE_NEW, &req, sizeof(req)); + msm_pipe_get_param(pipe, FD_NR_RINGS, &nr_rings); + + req.prio = MIN2(req.prio, MAX2(nr_rings, 1) - 1); + + ret = drmCommandWriteRead(pipe->dev->fd, DRM_MSM_SUBMITQUEUE_NEW, + &req, sizeof(req)); if (ret) { ERROR_MSG("could not create submitqueue! %d (%s)", ret, strerror(errno)); return ret; } - *queue_id = req.id; + to_msm_pipe(pipe)->queue_id = req.id; return 0; } -static void close_submitqueue(struct fd_device *dev, uint32_t queue_id) +static void close_submitqueue(struct fd_pipe *pipe, uint32_t queue_id) { - if (fd_device_version(dev) < FD_VERSION_SUBMIT_QUEUES) + if (fd_device_version(pipe->dev) < FD_VERSION_SUBMIT_QUEUES) return; - drmCommandWrite(dev->fd, DRM_MSM_SUBMITQUEUE_CLOSE, &queue_id, sizeof(queue_id)); + drmCommandWrite(pipe->dev->fd, DRM_MSM_SUBMITQUEUE_CLOSE, + &queue_id, sizeof(queue_id)); } static void msm_pipe_destroy(struct fd_pipe *pipe) { struct msm_pipe *msm_pipe = to_msm_pipe(pipe); - close_submitqueue(pipe->dev, msm_pipe->queue_id); + close_submitqueue(pipe, msm_pipe->queue_id); free(msm_pipe); } @@ -193,7 +199,7 @@ drm_private struct fd_pipe * msm_pipe_new(struct fd_device *dev, INFO_MSG(" Chip-id: 0x%08x", msm_pipe->chip_id); INFO_MSG(" GMEM size: 0x%08x", msm_pipe->gmem); - if (open_submitqueue(dev, prio, &msm_pipe->queue_id)) + if (open_submitqueue(pipe, prio)) goto fail; return pipe; |