[4/7] drm/radeon: Fill out gem_object->resv
diff mbox series

Message ID 20190625204208.5614-5-daniel.vetter@ffwll.ch
State New
Headers show
Series
  • gem_bo.resv prime unification, leftovers
Related show

Commit Message

Daniel Vetter June 25, 2019, 8:42 p.m. UTC
That way we can ditch our gem_prime_res_obj implementation. Since ttm
absolutely needs the right reservation object all the boilerplate is
already there and we just have to wire it up correctly.

Note that gem/prime doesn't care when we do this, as long as we do it
before the bo is registered and someone can call the handle2fd ioctl
on it.

Aside: ttm_buffer_object.ttm_resv could probably be ditched in favour
of always passing a non-NULL resv to ttm_bo_init(). At least for gem
drivers that would avoid having two of these, on in ttm_buffer_object
and the other in drm_gem_object, one just there for confusion.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: "David (ChunMing) Zhou" <David1.Zhou@amd.com>
Cc: amd-gfx@lists.freedesktop.org
---
 drivers/gpu/drm/radeon/radeon_drv.c    | 2 --
 drivers/gpu/drm/radeon/radeon_object.c | 1 +
 drivers/gpu/drm/radeon/radeon_prime.c  | 7 -------
 3 files changed, 1 insertion(+), 9 deletions(-)

Comments

Sam Ravnborg June 25, 2019, 8:52 p.m. UTC | #1
On Tue, Jun 25, 2019 at 10:42:05PM +0200, Daniel Vetter wrote:
> That way we can ditch our gem_prime_res_obj implementation. Since ttm
> absolutely needs the right reservation object all the boilerplate is
> already there and we just have to wire it up correctly.
> 
> Note that gem/prime doesn't care when we do this, as long as we do it
> before the bo is registered and someone can call the handle2fd ioctl
> on it.
> 
> Aside: ttm_buffer_object.ttm_resv could probably be ditched in favour
> of always passing a non-NULL resv to ttm_bo_init(). At least for gem
> drivers that would avoid having two of these, on in ttm_buffer_object
> and the other in drm_gem_object, one just there for confusion.
Something for todo.rst - so this does not get lost in a changelog
people will soon forget?

	Sam
Koenig, Christian June 26, 2019, 7:10 a.m. UTC | #2
Those patches would become superfluous when merging Gerd's work.

But I'm not sure if that is going to fly soon or not.

Christian.

Am 25.06.19 um 22:42 schrieb Daniel Vetter:
> That way we can ditch our gem_prime_res_obj implementation. Since ttm
> absolutely needs the right reservation object all the boilerplate is
> already there and we just have to wire it up correctly.
>
> Note that gem/prime doesn't care when we do this, as long as we do it
> before the bo is registered and someone can call the handle2fd ioctl
> on it.
>
> Aside: ttm_buffer_object.ttm_resv could probably be ditched in favour
> of always passing a non-NULL resv to ttm_bo_init(). At least for gem
> drivers that would avoid having two of these, on in ttm_buffer_object
> and the other in drm_gem_object, one just there for confusion.
>
> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: "Christian König" <christian.koenig@amd.com>
> Cc: "David (ChunMing) Zhou" <David1.Zhou@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
> ---
>   drivers/gpu/drm/radeon/radeon_drv.c    | 2 --
>   drivers/gpu/drm/radeon/radeon_object.c | 1 +
>   drivers/gpu/drm/radeon/radeon_prime.c  | 7 -------
>   3 files changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
> index 4403e76e1ae0..a4a78dfdef37 100644
> --- a/drivers/gpu/drm/radeon/radeon_drv.c
> +++ b/drivers/gpu/drm/radeon/radeon_drv.c
> @@ -152,7 +152,6 @@ struct drm_gem_object *radeon_gem_prime_import_sg_table(struct drm_device *dev,
>   							struct sg_table *sg);
>   int radeon_gem_prime_pin(struct drm_gem_object *obj);
>   void radeon_gem_prime_unpin(struct drm_gem_object *obj);
> -struct reservation_object *radeon_gem_prime_res_obj(struct drm_gem_object *);
>   void *radeon_gem_prime_vmap(struct drm_gem_object *obj);
>   void radeon_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
>   
> @@ -566,7 +565,6 @@ static struct drm_driver kms_driver = {
>   	.gem_prime_export = radeon_gem_prime_export,
>   	.gem_prime_pin = radeon_gem_prime_pin,
>   	.gem_prime_unpin = radeon_gem_prime_unpin,
> -	.gem_prime_res_obj = radeon_gem_prime_res_obj,
>   	.gem_prime_get_sg_table = radeon_gem_prime_get_sg_table,
>   	.gem_prime_import_sg_table = radeon_gem_prime_import_sg_table,
>   	.gem_prime_vmap = radeon_gem_prime_vmap,
> diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
> index 21f73fc86f38..7a2bad843f8a 100644
> --- a/drivers/gpu/drm/radeon/radeon_object.c
> +++ b/drivers/gpu/drm/radeon/radeon_object.c
> @@ -262,6 +262,7 @@ int radeon_bo_create(struct radeon_device *rdev,
>   	r = ttm_bo_init(&rdev->mman.bdev, &bo->tbo, size, type,
>   			&bo->placement, page_align, !kernel, acc_size,
>   			sg, resv, &radeon_ttm_bo_destroy);
> +	bo->gem_base.resv = bo->tbo.resv;
>   	up_read(&rdev->pm.mclk_lock);
>   	if (unlikely(r != 0)) {
>   		return r;
> diff --git a/drivers/gpu/drm/radeon/radeon_prime.c b/drivers/gpu/drm/radeon/radeon_prime.c
> index deaffce50a2e..8ce3e8045d42 100644
> --- a/drivers/gpu/drm/radeon/radeon_prime.c
> +++ b/drivers/gpu/drm/radeon/radeon_prime.c
> @@ -117,13 +117,6 @@ void radeon_gem_prime_unpin(struct drm_gem_object *obj)
>   }
>   
>   
> -struct reservation_object *radeon_gem_prime_res_obj(struct drm_gem_object *obj)
> -{
> -	struct radeon_bo *bo = gem_to_radeon_bo(obj);
> -
> -	return bo->tbo.resv;
> -}
> -
>   struct dma_buf *radeon_gem_prime_export(struct drm_gem_object *gobj,
>   					int flags)
>   {
Daniel Vetter June 26, 2019, 8:23 a.m. UTC | #3
On Wed, Jun 26, 2019 at 07:10:21AM +0000, Koenig, Christian wrote:
> Those patches would become superfluous when merging Gerd's work.

Not entirely, they still remove the gem_prime_res_obj. Setting up
gem_bo.resv is only one half of what these do here. And yeah I think that
single addition can be removed again when Gerd's stuff lands.
 
> But I'm not sure if that is going to fly soon or not.

I think r-b from Thomas Zimmermann (or some other ttm+gem stakeholder) and
we're good to land them. Thomas Hellstrom mellowed down his "nack" to
"I'll look at this in August again and course-correct if necessary".
-Daniel

> 
> Christian.
> 
> Am 25.06.19 um 22:42 schrieb Daniel Vetter:
> > That way we can ditch our gem_prime_res_obj implementation. Since ttm
> > absolutely needs the right reservation object all the boilerplate is
> > already there and we just have to wire it up correctly.
> >
> > Note that gem/prime doesn't care when we do this, as long as we do it
> > before the bo is registered and someone can call the handle2fd ioctl
> > on it.
> >
> > Aside: ttm_buffer_object.ttm_resv could probably be ditched in favour
> > of always passing a non-NULL resv to ttm_bo_init(). At least for gem
> > drivers that would avoid having two of these, on in ttm_buffer_object
> > and the other in drm_gem_object, one just there for confusion.
> >
> > Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Alex Deucher <alexander.deucher@amd.com>
> > Cc: "Christian König" <christian.koenig@amd.com>
> > Cc: "David (ChunMing) Zhou" <David1.Zhou@amd.com>
> > Cc: amd-gfx@lists.freedesktop.org
> > ---
> >   drivers/gpu/drm/radeon/radeon_drv.c    | 2 --
> >   drivers/gpu/drm/radeon/radeon_object.c | 1 +
> >   drivers/gpu/drm/radeon/radeon_prime.c  | 7 -------
> >   3 files changed, 1 insertion(+), 9 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
> > index 4403e76e1ae0..a4a78dfdef37 100644
> > --- a/drivers/gpu/drm/radeon/radeon_drv.c
> > +++ b/drivers/gpu/drm/radeon/radeon_drv.c
> > @@ -152,7 +152,6 @@ struct drm_gem_object *radeon_gem_prime_import_sg_table(struct drm_device *dev,
> >   							struct sg_table *sg);
> >   int radeon_gem_prime_pin(struct drm_gem_object *obj);
> >   void radeon_gem_prime_unpin(struct drm_gem_object *obj);
> > -struct reservation_object *radeon_gem_prime_res_obj(struct drm_gem_object *);
> >   void *radeon_gem_prime_vmap(struct drm_gem_object *obj);
> >   void radeon_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
> >   
> > @@ -566,7 +565,6 @@ static struct drm_driver kms_driver = {
> >   	.gem_prime_export = radeon_gem_prime_export,
> >   	.gem_prime_pin = radeon_gem_prime_pin,
> >   	.gem_prime_unpin = radeon_gem_prime_unpin,
> > -	.gem_prime_res_obj = radeon_gem_prime_res_obj,
> >   	.gem_prime_get_sg_table = radeon_gem_prime_get_sg_table,
> >   	.gem_prime_import_sg_table = radeon_gem_prime_import_sg_table,
> >   	.gem_prime_vmap = radeon_gem_prime_vmap,
> > diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
> > index 21f73fc86f38..7a2bad843f8a 100644
> > --- a/drivers/gpu/drm/radeon/radeon_object.c
> > +++ b/drivers/gpu/drm/radeon/radeon_object.c
> > @@ -262,6 +262,7 @@ int radeon_bo_create(struct radeon_device *rdev,
> >   	r = ttm_bo_init(&rdev->mman.bdev, &bo->tbo, size, type,
> >   			&bo->placement, page_align, !kernel, acc_size,
> >   			sg, resv, &radeon_ttm_bo_destroy);
> > +	bo->gem_base.resv = bo->tbo.resv;
> >   	up_read(&rdev->pm.mclk_lock);
> >   	if (unlikely(r != 0)) {
> >   		return r;
> > diff --git a/drivers/gpu/drm/radeon/radeon_prime.c b/drivers/gpu/drm/radeon/radeon_prime.c
> > index deaffce50a2e..8ce3e8045d42 100644
> > --- a/drivers/gpu/drm/radeon/radeon_prime.c
> > +++ b/drivers/gpu/drm/radeon/radeon_prime.c
> > @@ -117,13 +117,6 @@ void radeon_gem_prime_unpin(struct drm_gem_object *obj)
> >   }
> >   
> >   
> > -struct reservation_object *radeon_gem_prime_res_obj(struct drm_gem_object *obj)
> > -{
> > -	struct radeon_bo *bo = gem_to_radeon_bo(obj);
> > -
> > -	return bo->tbo.resv;
> > -}
> > -
> >   struct dma_buf *radeon_gem_prime_export(struct drm_gem_object *gobj,
> >   					int flags)
> >   {
>
Daniel Vetter June 27, 2019, 7:33 a.m. UTC | #4
On Wed, Jun 26, 2019 at 10:23:12AM +0200, Daniel Vetter wrote:
> On Wed, Jun 26, 2019 at 07:10:21AM +0000, Koenig, Christian wrote:
> > Those patches would become superfluous when merging Gerd's work.
> 
> Not entirely, they still remove the gem_prime_res_obj. Setting up
> gem_bo.resv is only one half of what these do here. And yeah I think that
> single addition can be removed again when Gerd's stuff lands.
>  
> > But I'm not sure if that is going to fly soon or not.
> 
> I think r-b from Thomas Zimmermann (or some other ttm+gem stakeholder) and
> we're good to land them. Thomas Hellstrom mellowed down his "nack" to
> "I'll look at this in August again and course-correct if necessary".

Just pinged Gerd on this, so we can start coordination.

btw planning to review this from amd side, I'd like to ditch
gem_prime_res_obj especially with Gerd series it's pointless.
-Daniel

> -Daniel
> 
> > 
> > Christian.
> > 
> > Am 25.06.19 um 22:42 schrieb Daniel Vetter:
> > > That way we can ditch our gem_prime_res_obj implementation. Since ttm
> > > absolutely needs the right reservation object all the boilerplate is
> > > already there and we just have to wire it up correctly.
> > >
> > > Note that gem/prime doesn't care when we do this, as long as we do it
> > > before the bo is registered and someone can call the handle2fd ioctl
> > > on it.
> > >
> > > Aside: ttm_buffer_object.ttm_resv could probably be ditched in favour
> > > of always passing a non-NULL resv to ttm_bo_init(). At least for gem
> > > drivers that would avoid having two of these, on in ttm_buffer_object
> > > and the other in drm_gem_object, one just there for confusion.
> > >
> > > Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > Cc: Alex Deucher <alexander.deucher@amd.com>
> > > Cc: "Christian König" <christian.koenig@amd.com>
> > > Cc: "David (ChunMing) Zhou" <David1.Zhou@amd.com>
> > > Cc: amd-gfx@lists.freedesktop.org
> > > ---
> > >   drivers/gpu/drm/radeon/radeon_drv.c    | 2 --
> > >   drivers/gpu/drm/radeon/radeon_object.c | 1 +
> > >   drivers/gpu/drm/radeon/radeon_prime.c  | 7 -------
> > >   3 files changed, 1 insertion(+), 9 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
> > > index 4403e76e1ae0..a4a78dfdef37 100644
> > > --- a/drivers/gpu/drm/radeon/radeon_drv.c
> > > +++ b/drivers/gpu/drm/radeon/radeon_drv.c
> > > @@ -152,7 +152,6 @@ struct drm_gem_object *radeon_gem_prime_import_sg_table(struct drm_device *dev,
> > >   							struct sg_table *sg);
> > >   int radeon_gem_prime_pin(struct drm_gem_object *obj);
> > >   void radeon_gem_prime_unpin(struct drm_gem_object *obj);
> > > -struct reservation_object *radeon_gem_prime_res_obj(struct drm_gem_object *);
> > >   void *radeon_gem_prime_vmap(struct drm_gem_object *obj);
> > >   void radeon_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
> > >   
> > > @@ -566,7 +565,6 @@ static struct drm_driver kms_driver = {
> > >   	.gem_prime_export = radeon_gem_prime_export,
> > >   	.gem_prime_pin = radeon_gem_prime_pin,
> > >   	.gem_prime_unpin = radeon_gem_prime_unpin,
> > > -	.gem_prime_res_obj = radeon_gem_prime_res_obj,
> > >   	.gem_prime_get_sg_table = radeon_gem_prime_get_sg_table,
> > >   	.gem_prime_import_sg_table = radeon_gem_prime_import_sg_table,
> > >   	.gem_prime_vmap = radeon_gem_prime_vmap,
> > > diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
> > > index 21f73fc86f38..7a2bad843f8a 100644
> > > --- a/drivers/gpu/drm/radeon/radeon_object.c
> > > +++ b/drivers/gpu/drm/radeon/radeon_object.c
> > > @@ -262,6 +262,7 @@ int radeon_bo_create(struct radeon_device *rdev,
> > >   	r = ttm_bo_init(&rdev->mman.bdev, &bo->tbo, size, type,
> > >   			&bo->placement, page_align, !kernel, acc_size,
> > >   			sg, resv, &radeon_ttm_bo_destroy);
> > > +	bo->gem_base.resv = bo->tbo.resv;
> > >   	up_read(&rdev->pm.mclk_lock);
> > >   	if (unlikely(r != 0)) {
> > >   		return r;
> > > diff --git a/drivers/gpu/drm/radeon/radeon_prime.c b/drivers/gpu/drm/radeon/radeon_prime.c
> > > index deaffce50a2e..8ce3e8045d42 100644
> > > --- a/drivers/gpu/drm/radeon/radeon_prime.c
> > > +++ b/drivers/gpu/drm/radeon/radeon_prime.c
> > > @@ -117,13 +117,6 @@ void radeon_gem_prime_unpin(struct drm_gem_object *obj)
> > >   }
> > >   
> > >   
> > > -struct reservation_object *radeon_gem_prime_res_obj(struct drm_gem_object *obj)
> > > -{
> > > -	struct radeon_bo *bo = gem_to_radeon_bo(obj);
> > > -
> > > -	return bo->tbo.resv;
> > > -}
> > > -
> > >   struct dma_buf *radeon_gem_prime_export(struct drm_gem_object *gobj,
> > >   					int flags)
> > >   {
> > 
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
Daniel Vetter July 19, 2019, 1 p.m. UTC | #5
On Thu, Jun 27, 2019 at 09:33:50AM +0200, Daniel Vetter wrote:
> On Wed, Jun 26, 2019 at 10:23:12AM +0200, Daniel Vetter wrote:
> > On Wed, Jun 26, 2019 at 07:10:21AM +0000, Koenig, Christian wrote:
> > > Those patches would become superfluous when merging Gerd's work.
> > 
> > Not entirely, they still remove the gem_prime_res_obj. Setting up
> > gem_bo.resv is only one half of what these do here. And yeah I think that
> > single addition can be removed again when Gerd's stuff lands.
> >  
> > > But I'm not sure if that is going to fly soon or not.
> > 
> > I think r-b from Thomas Zimmermann (or some other ttm+gem stakeholder) and
> > we're good to land them. Thomas Hellstrom mellowed down his "nack" to
> > "I'll look at this in August again and course-correct if necessary".
> 
> Just pinged Gerd on this, so we can start coordination.
> 
> btw planning to review this from amd side, I'd like to ditch
> gem_prime_res_obj especially with Gerd series it's pointless.

Gerd rebased his series on top of this, so review would be neat to unblock
everything. I'd like to get this all landed for 5.4.

Thanks, Daniel

> -Daniel
> 
> > -Daniel
> > 
> > > 
> > > Christian.
> > > 
> > > Am 25.06.19 um 22:42 schrieb Daniel Vetter:
> > > > That way we can ditch our gem_prime_res_obj implementation. Since ttm
> > > > absolutely needs the right reservation object all the boilerplate is
> > > > already there and we just have to wire it up correctly.
> > > >
> > > > Note that gem/prime doesn't care when we do this, as long as we do it
> > > > before the bo is registered and someone can call the handle2fd ioctl
> > > > on it.
> > > >
> > > > Aside: ttm_buffer_object.ttm_resv could probably be ditched in favour
> > > > of always passing a non-NULL resv to ttm_bo_init(). At least for gem
> > > > drivers that would avoid having two of these, on in ttm_buffer_object
> > > > and the other in drm_gem_object, one just there for confusion.
> > > >
> > > > Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
> > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > > Cc: Alex Deucher <alexander.deucher@amd.com>
> > > > Cc: "Christian König" <christian.koenig@amd.com>
> > > > Cc: "David (ChunMing) Zhou" <David1.Zhou@amd.com>
> > > > Cc: amd-gfx@lists.freedesktop.org
> > > > ---
> > > >   drivers/gpu/drm/radeon/radeon_drv.c    | 2 --
> > > >   drivers/gpu/drm/radeon/radeon_object.c | 1 +
> > > >   drivers/gpu/drm/radeon/radeon_prime.c  | 7 -------
> > > >   3 files changed, 1 insertion(+), 9 deletions(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
> > > > index 4403e76e1ae0..a4a78dfdef37 100644
> > > > --- a/drivers/gpu/drm/radeon/radeon_drv.c
> > > > +++ b/drivers/gpu/drm/radeon/radeon_drv.c
> > > > @@ -152,7 +152,6 @@ struct drm_gem_object *radeon_gem_prime_import_sg_table(struct drm_device *dev,
> > > >   							struct sg_table *sg);
> > > >   int radeon_gem_prime_pin(struct drm_gem_object *obj);
> > > >   void radeon_gem_prime_unpin(struct drm_gem_object *obj);
> > > > -struct reservation_object *radeon_gem_prime_res_obj(struct drm_gem_object *);
> > > >   void *radeon_gem_prime_vmap(struct drm_gem_object *obj);
> > > >   void radeon_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
> > > >   
> > > > @@ -566,7 +565,6 @@ static struct drm_driver kms_driver = {
> > > >   	.gem_prime_export = radeon_gem_prime_export,
> > > >   	.gem_prime_pin = radeon_gem_prime_pin,
> > > >   	.gem_prime_unpin = radeon_gem_prime_unpin,
> > > > -	.gem_prime_res_obj = radeon_gem_prime_res_obj,
> > > >   	.gem_prime_get_sg_table = radeon_gem_prime_get_sg_table,
> > > >   	.gem_prime_import_sg_table = radeon_gem_prime_import_sg_table,
> > > >   	.gem_prime_vmap = radeon_gem_prime_vmap,
> > > > diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
> > > > index 21f73fc86f38..7a2bad843f8a 100644
> > > > --- a/drivers/gpu/drm/radeon/radeon_object.c
> > > > +++ b/drivers/gpu/drm/radeon/radeon_object.c
> > > > @@ -262,6 +262,7 @@ int radeon_bo_create(struct radeon_device *rdev,
> > > >   	r = ttm_bo_init(&rdev->mman.bdev, &bo->tbo, size, type,
> > > >   			&bo->placement, page_align, !kernel, acc_size,
> > > >   			sg, resv, &radeon_ttm_bo_destroy);
> > > > +	bo->gem_base.resv = bo->tbo.resv;
> > > >   	up_read(&rdev->pm.mclk_lock);
> > > >   	if (unlikely(r != 0)) {
> > > >   		return r;
> > > > diff --git a/drivers/gpu/drm/radeon/radeon_prime.c b/drivers/gpu/drm/radeon/radeon_prime.c
> > > > index deaffce50a2e..8ce3e8045d42 100644
> > > > --- a/drivers/gpu/drm/radeon/radeon_prime.c
> > > > +++ b/drivers/gpu/drm/radeon/radeon_prime.c
> > > > @@ -117,13 +117,6 @@ void radeon_gem_prime_unpin(struct drm_gem_object *obj)
> > > >   }
> > > >   
> > > >   
> > > > -struct reservation_object *radeon_gem_prime_res_obj(struct drm_gem_object *obj)
> > > > -{
> > > > -	struct radeon_bo *bo = gem_to_radeon_bo(obj);
> > > > -
> > > > -	return bo->tbo.resv;
> > > > -}
> > > > -
> > > >   struct dma_buf *radeon_gem_prime_export(struct drm_gem_object *gobj,
> > > >   					int flags)
> > > >   {
> > > 
> > 
> > -- 
> > Daniel Vetter
> > Software Engineer, Intel Corporation
> > http://blog.ffwll.ch
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
Daniel Vetter July 25, 2019, 1:18 p.m. UTC | #6
On Tue, Jun 25, 2019 at 10:52:17PM +0200, Sam Ravnborg wrote:
> On Tue, Jun 25, 2019 at 10:42:05PM +0200, Daniel Vetter wrote:
> > That way we can ditch our gem_prime_res_obj implementation. Since ttm
> > absolutely needs the right reservation object all the boilerplate is
> > already there and we just have to wire it up correctly.
> > 
> > Note that gem/prime doesn't care when we do this, as long as we do it
> > before the bo is registered and someone can call the handle2fd ioctl
> > on it.
> > 
> > Aside: ttm_buffer_object.ttm_resv could probably be ditched in favour
> > of always passing a non-NULL resv to ttm_bo_init(). At least for gem
> > drivers that would avoid having two of these, on in ttm_buffer_object
> > and the other in drm_gem_object, one just there for confusion.
> Something for todo.rst - so this does not get lost in a changelog
> people will soon forget?

Gerd already has a nice patch series (rebased onto this one), so I don't
think we need a todo.rst for this.
-Daniel

Patch
diff mbox series

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 4403e76e1ae0..a4a78dfdef37 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -152,7 +152,6 @@  struct drm_gem_object *radeon_gem_prime_import_sg_table(struct drm_device *dev,
 							struct sg_table *sg);
 int radeon_gem_prime_pin(struct drm_gem_object *obj);
 void radeon_gem_prime_unpin(struct drm_gem_object *obj);
-struct reservation_object *radeon_gem_prime_res_obj(struct drm_gem_object *);
 void *radeon_gem_prime_vmap(struct drm_gem_object *obj);
 void radeon_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
 
@@ -566,7 +565,6 @@  static struct drm_driver kms_driver = {
 	.gem_prime_export = radeon_gem_prime_export,
 	.gem_prime_pin = radeon_gem_prime_pin,
 	.gem_prime_unpin = radeon_gem_prime_unpin,
-	.gem_prime_res_obj = radeon_gem_prime_res_obj,
 	.gem_prime_get_sg_table = radeon_gem_prime_get_sg_table,
 	.gem_prime_import_sg_table = radeon_gem_prime_import_sg_table,
 	.gem_prime_vmap = radeon_gem_prime_vmap,
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index 21f73fc86f38..7a2bad843f8a 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -262,6 +262,7 @@  int radeon_bo_create(struct radeon_device *rdev,
 	r = ttm_bo_init(&rdev->mman.bdev, &bo->tbo, size, type,
 			&bo->placement, page_align, !kernel, acc_size,
 			sg, resv, &radeon_ttm_bo_destroy);
+	bo->gem_base.resv = bo->tbo.resv;
 	up_read(&rdev->pm.mclk_lock);
 	if (unlikely(r != 0)) {
 		return r;
diff --git a/drivers/gpu/drm/radeon/radeon_prime.c b/drivers/gpu/drm/radeon/radeon_prime.c
index deaffce50a2e..8ce3e8045d42 100644
--- a/drivers/gpu/drm/radeon/radeon_prime.c
+++ b/drivers/gpu/drm/radeon/radeon_prime.c
@@ -117,13 +117,6 @@  void radeon_gem_prime_unpin(struct drm_gem_object *obj)
 }
 
 
-struct reservation_object *radeon_gem_prime_res_obj(struct drm_gem_object *obj)
-{
-	struct radeon_bo *bo = gem_to_radeon_bo(obj);
-
-	return bo->tbo.resv;
-}
-
 struct dma_buf *radeon_gem_prime_export(struct drm_gem_object *gobj,
 					int flags)
 {