On Tue, Sep 15, 2020 at 04:59:46PM +0200, Thomas Zimmermann wrote: > GEM object functions deprecate several similar callback interfaces in > struct drm_driver. This patch replaces the per-driver callbacks with > per-instance callbacks in nouveau. > > Signed-off-by: Thomas Zimmermann <tzimmermann@xxxxxxx> Hm ttm and gem mmap world still quite disjoint ... Anyway that's an entirely different thing. Reviewed-by: Daniel Vetter <daniel.vetter@xxxxxxxx> > --- > drivers/gpu/drm/nouveau/nouveau_drm.c | 9 --------- > drivers/gpu/drm/nouveau/nouveau_gem.c | 13 +++++++++++++ > drivers/gpu/drm/nouveau/nouveau_gem.h | 2 ++ > drivers/gpu/drm/nouveau/nouveau_prime.c | 2 ++ > 4 files changed, 17 insertions(+), 9 deletions(-) > > diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c > index 42fc5c813a9b..72640bca1617 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_drm.c > +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c > @@ -1207,16 +1207,7 @@ driver_stub = { > > .prime_handle_to_fd = drm_gem_prime_handle_to_fd, > .prime_fd_to_handle = drm_gem_prime_fd_to_handle, > - .gem_prime_pin = nouveau_gem_prime_pin, > - .gem_prime_unpin = nouveau_gem_prime_unpin, > - .gem_prime_get_sg_table = nouveau_gem_prime_get_sg_table, > .gem_prime_import_sg_table = nouveau_gem_prime_import_sg_table, > - .gem_prime_vmap = nouveau_gem_prime_vmap, > - .gem_prime_vunmap = nouveau_gem_prime_vunmap, > - > - .gem_free_object_unlocked = nouveau_gem_object_del, > - .gem_open_object = nouveau_gem_object_open, > - .gem_close_object = nouveau_gem_object_close, > > .dumb_create = nouveau_display_dumb_create, > .dumb_map_offset = nouveau_display_dumb_map_offset, > diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c > index 89adadf4706b..28e0cbb00876 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_gem.c > +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c > @@ -169,6 +169,17 @@ nouveau_gem_object_close(struct drm_gem_object *gem, struct drm_file *file_priv) > ttm_bo_unreserve(&nvbo->bo); > } > > +const struct drm_gem_object_funcs nouveau_gem_object_funcs = { > + .free = nouveau_gem_object_del, > + .open = nouveau_gem_object_open, > + .close = nouveau_gem_object_close, > + .pin = nouveau_gem_prime_pin, > + .unpin = nouveau_gem_prime_unpin, > + .get_sg_table = nouveau_gem_prime_get_sg_table, > + .vmap = nouveau_gem_prime_vmap, > + .vunmap = nouveau_gem_prime_vunmap, > +}; > + > int > nouveau_gem_new(struct nouveau_cli *cli, u64 size, int align, uint32_t domain, > uint32_t tile_mode, uint32_t tile_flags, > @@ -186,6 +197,8 @@ nouveau_gem_new(struct nouveau_cli *cli, u64 size, int align, uint32_t domain, > if (IS_ERR(nvbo)) > return PTR_ERR(nvbo); > > + nvbo->bo.base.funcs = &nouveau_gem_object_funcs; > + > /* Initialize the embedded gem-object. We return a single gem-reference > * to the caller, instead of a normal nouveau_bo ttm reference. */ > ret = drm_gem_object_init(drm->dev, &nvbo->bo.base, size); > diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.h b/drivers/gpu/drm/nouveau/nouveau_gem.h > index 978e07591990..b35c180322e2 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_gem.h > +++ b/drivers/gpu/drm/nouveau/nouveau_gem.h > @@ -5,6 +5,8 @@ > #include "nouveau_drv.h" > #include "nouveau_bo.h" > > +extern const struct drm_gem_object_funcs nouveau_gem_object_funcs; > + > static inline struct nouveau_bo * > nouveau_gem_object(struct drm_gem_object *gem) > { > diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c b/drivers/gpu/drm/nouveau/nouveau_prime.c > index b2ecb91f8ddc..a8264aebf3d4 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_prime.c > +++ b/drivers/gpu/drm/nouveau/nouveau_prime.c > @@ -77,6 +77,8 @@ struct drm_gem_object *nouveau_gem_prime_import_sg_table(struct drm_device *dev, > > nvbo->valid_domains = NOUVEAU_GEM_DOMAIN_GART; > > + nvbo->bo.base.funcs = &nouveau_gem_object_funcs; > + > /* Initialize the embedded gem-object. We return a single gem-reference > * to the caller, instead of a normal nouveau_bo ttm reference. */ > ret = drm_gem_object_init(dev, &nvbo->bo.base, size); > -- > 2.28.0 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch