From: Rob Clark Date: Wed, 9 Jan 2019 18:03:43 +0000 (-0500) Subject: freedreno: make cmdstream bo's read-only to GPU X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=04aff7e42b88fdd251617436a589ea0be2f44093;p=mesa.git freedreno: make cmdstream bo's read-only to GPU If nothing else, this will make problems with cmdstream getting blit over with pixels easier to track down (ie. faults when it first happens rather than strange failures later from corrupted cmdstream when a stateobj is later reused). (NOTE this somewhat depends on the kernel supporting the flag, and the iommu implementation. But the worst case is just that the cmdstream ends up writeable as before.) Signed-off-by: Rob Clark --- diff --git a/src/freedreno/drm/msm_bo.c b/src/freedreno/drm/msm_bo.c index fd9955ea805..da2609903c1 100644 --- a/src/freedreno/drm/msm_bo.c +++ b/src/freedreno/drm/msm_bo.c @@ -166,6 +166,9 @@ int msm_bo_new_handle(struct fd_device *dev, if (flags & DRM_FREEDRENO_GEM_SCANOUT) req.flags |= MSM_BO_SCANOUT; + if (flags & DRM_FREEDRENO_GEM_GPUREADONLY) + req.flags |= MSM_BO_GPU_READONLY; + ret = drmCommandWriteRead(dev->fd, DRM_MSM_GEM_NEW, &req, sizeof(req)); if (ret) diff --git a/src/freedreno/drm/msm_ringbuffer_sp.c b/src/freedreno/drm/msm_ringbuffer_sp.c index 228740d783b..2b8f531721e 100644 --- a/src/freedreno/drm/msm_ringbuffer_sp.c +++ b/src/freedreno/drm/msm_ringbuffer_sp.c @@ -186,8 +186,8 @@ msm_submit_suballoc_ring_bo(struct fd_submit *submit, if (!suballoc_bo) { // TODO possibly larger size for streaming bo? - msm_ring->ring_bo = fd_bo_new_ring( - submit->pipe->dev, 0x8000, 0); + msm_ring->ring_bo = fd_bo_new_ring(submit->pipe->dev, + 0x8000, DRM_FREEDRENO_GEM_GPUREADONLY); msm_ring->offset = 0; } else { msm_ring->ring_bo = fd_bo_ref(suballoc_bo); @@ -225,7 +225,8 @@ msm_submit_sp_new_ringbuffer(struct fd_submit *submit, uint32_t size, size = INIT_SIZE; msm_ring->offset = 0; - msm_ring->ring_bo = fd_bo_new_ring(submit->pipe->dev, size, 0); + msm_ring->ring_bo = fd_bo_new_ring(submit->pipe->dev, size, + DRM_FREEDRENO_GEM_GPUREADONLY); } if (!msm_ringbuffer_sp_init(msm_ring, size, flags)) @@ -375,7 +376,8 @@ msm_ringbuffer_sp_grow(struct fd_ringbuffer *ring, uint32_t size) finalize_current_cmd(ring); fd_bo_del(msm_ring->ring_bo); - msm_ring->ring_bo = fd_bo_new_ring(pipe->dev, size, 0); + msm_ring->ring_bo = fd_bo_new_ring(pipe->dev, size, + DRM_FREEDRENO_GEM_GPUREADONLY); ring->start = fd_bo_map(msm_ring->ring_bo); ring->end = &(ring->start[size/4]); @@ -558,7 +560,8 @@ msm_ringbuffer_sp_new_object(struct fd_pipe *pipe, uint32_t size) msm_ring->u.pipe = pipe; msm_ring->offset = 0; - msm_ring->ring_bo = fd_bo_new_ring(pipe->dev, size, 0); + msm_ring->ring_bo = fd_bo_new_ring(pipe->dev, size, + DRM_FREEDRENO_GEM_GPUREADONLY); msm_ring->base.refcnt = 1; return msm_ringbuffer_sp_init(msm_ring, size, _FD_RINGBUFFER_OBJECT);