Message ID | 20230402164826.752842-6-dmitry.osipenko@collabora.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Move dma-buf mmap() reservation locking down to exporters | expand |
Am 02.04.23 um 18:48 schrieb Dmitry Osipenko: > Don't assert held dma-buf reservation lock on memory mapping of exported > buffer. > > We're going to change dma-buf mmap() locking policy such that exporters > will have to handle the lock. The previous locking policy caused deadlock > problem for DRM drivers in a case of self-imported dma-bufs, it's solved > by moving the lock down to exporters. I only checked the TTM code path and think that at least that one should work fine. > Fixes: 39ce25291871 ("drm: Assert held reservation lock for dma-buf mmapping") This here is not really a "fix" for the previous patch. We just found that we didn't like the behavior and so reverted the original patch. A "Reverts..." comment in the commit message would be more appropriate I think. > Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Acked-by: Christian König <christian.koenig@amd.com> Regards, Christian. > --- > drivers/gpu/drm/drm_prime.c | 2 -- > drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 2 -- > drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 2 -- > drivers/gpu/drm/tegra/gem.c | 2 -- > 4 files changed, 8 deletions(-) > > diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c > index 149cd4ff6a3b..cea85e84666f 100644 > --- a/drivers/gpu/drm/drm_prime.c > +++ b/drivers/gpu/drm/drm_prime.c > @@ -781,8 +781,6 @@ int drm_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struct *vma) > struct drm_gem_object *obj = dma_buf->priv; > struct drm_device *dev = obj->dev; > > - dma_resv_assert_held(dma_buf->resv); > - > if (!dev->driver->gem_prime_mmap) > return -ENOSYS; > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c > index fd556a076d05..1df74f7aa3dc 100644 > --- a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c > +++ b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c > @@ -97,8 +97,6 @@ static int i915_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struct * > struct drm_i915_private *i915 = to_i915(obj->base.dev); > int ret; > > - dma_resv_assert_held(dma_buf->resv); > - > if (obj->base.size < vma->vm_end - vma->vm_start) > return -EINVAL; > > diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c > index 3abc47521b2c..8e194dbc9506 100644 > --- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c > +++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c > @@ -66,8 +66,6 @@ static int omap_gem_dmabuf_mmap(struct dma_buf *buffer, > struct drm_gem_object *obj = buffer->priv; > int ret = 0; > > - dma_resv_assert_held(buffer->resv); > - > ret = drm_gem_mmap_obj(obj, omap_gem_mmap_size(obj), vma); > if (ret < 0) > return ret; > diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c > index bce991a2ccc0..871ef5d26523 100644 > --- a/drivers/gpu/drm/tegra/gem.c > +++ b/drivers/gpu/drm/tegra/gem.c > @@ -693,8 +693,6 @@ static int tegra_gem_prime_mmap(struct dma_buf *buf, struct vm_area_struct *vma) > struct drm_gem_object *gem = buf->priv; > int err; > > - dma_resv_assert_held(buf->resv); > - > err = drm_gem_mmap_obj(gem, gem->size, vma); > if (err < 0) > return err;
On 4/3/23 18:17, Christian König wrote: > Am 02.04.23 um 18:48 schrieb Dmitry Osipenko: >> Don't assert held dma-buf reservation lock on memory mapping of exported >> buffer. >> >> We're going to change dma-buf mmap() locking policy such that exporters >> will have to handle the lock. The previous locking policy caused deadlock >> problem for DRM drivers in a case of self-imported dma-bufs, it's solved >> by moving the lock down to exporters. > > I only checked the TTM code path and think that at least that one should > work fine. > >> Fixes: 39ce25291871 ("drm: Assert held reservation lock for dma-buf >> mmapping") > > This here is not really a "fix" for the previous patch. We just found > that we didn't like the behavior and so reverted the original patch. > > A "Reverts..." comment in the commit message would be more appropriate I > think. Ack, will drop the fixes tag in v2. Thank you and Emil for the review.
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 149cd4ff6a3b..cea85e84666f 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -781,8 +781,6 @@ int drm_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struct *vma) struct drm_gem_object *obj = dma_buf->priv; struct drm_device *dev = obj->dev; - dma_resv_assert_held(dma_buf->resv); - if (!dev->driver->gem_prime_mmap) return -ENOSYS; diff --git a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c index fd556a076d05..1df74f7aa3dc 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c @@ -97,8 +97,6 @@ static int i915_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struct * struct drm_i915_private *i915 = to_i915(obj->base.dev); int ret; - dma_resv_assert_held(dma_buf->resv); - if (obj->base.size < vma->vm_end - vma->vm_start) return -EINVAL; diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c index 3abc47521b2c..8e194dbc9506 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c +++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c @@ -66,8 +66,6 @@ static int omap_gem_dmabuf_mmap(struct dma_buf *buffer, struct drm_gem_object *obj = buffer->priv; int ret = 0; - dma_resv_assert_held(buffer->resv); - ret = drm_gem_mmap_obj(obj, omap_gem_mmap_size(obj), vma); if (ret < 0) return ret; diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c index bce991a2ccc0..871ef5d26523 100644 --- a/drivers/gpu/drm/tegra/gem.c +++ b/drivers/gpu/drm/tegra/gem.c @@ -693,8 +693,6 @@ static int tegra_gem_prime_mmap(struct dma_buf *buf, struct vm_area_struct *vma) struct drm_gem_object *gem = buf->priv; int err; - dma_resv_assert_held(buf->resv); - err = drm_gem_mmap_obj(gem, gem->size, vma); if (err < 0) return err;
Don't assert held dma-buf reservation lock on memory mapping of exported buffer. We're going to change dma-buf mmap() locking policy such that exporters will have to handle the lock. The previous locking policy caused deadlock problem for DRM drivers in a case of self-imported dma-bufs, it's solved by moving the lock down to exporters. Fixes: 39ce25291871 ("drm: Assert held reservation lock for dma-buf mmapping") Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> --- drivers/gpu/drm/drm_prime.c | 2 -- drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 2 -- drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 2 -- drivers/gpu/drm/tegra/gem.c | 2 -- 4 files changed, 8 deletions(-)