mbox series

[v4,0/7] drm: Clean up mmap for TTM-based GEM drivers

Message ID 20210525151055.8174-1-tzimmermann@suse.de (mailing list archive)
Headers show
Series drm: Clean up mmap for TTM-based GEM drivers | expand

Message

Thomas Zimmermann May 25, 2021, 3:10 p.m. UTC
Implement mmap via struct drm_gem_object_functions.mmap in amdgpu,
radeon and nouveau. This allows for using common DRM helpers for
the mmap-related callbacks in struct file_operations and struct
drm_driver. The drivers have their own vm_ops, which are now set
automatically by the DRM core functions. The code in each driver's
verify_access becomes part of the driver's new mmap implementation.

With the GEM drivers converted, vmwgfx is the only user of
ttm_bo_mmap() and related infrastructure. So move everything into
vmwgfx and delete the rsp code from TTM.

This touches several drivers. Preferably everything would be merged
at once via drm-misc-next.

v4:
	* rebase on top of amdgpu hot-unplug changes
v3:
	* tidy up the new mmap functions in amdgpu and radeon (Christian)
v2:
	* removal of amdgpu fbdev mmap already merged (Christian)
	* rebase on top of amdgpu fixes [1] (Felix)
	* replace pr_err() with drm_err() in vmwgfx patch (Zack)
	* several typos

[1] https://patchwork.freedesktop.org/series/88822/

Thomas Zimmermann (7):
  drm/ttm: Don't override vm_ops callbacks, if set
  drm/amdgpu: Implement mmap as GEM object function
  drm/radeon: Implement mmap as GEM object function
  drm/nouveau: Implement mmap as GEM object function
  drm/vmwgfx: Inline ttm_bo_mmap() into vmwgfx driver
  drm/vmwgfx: Inline vmw_verify_access()
  drm/ttm: Remove ttm_bo_mmap() and friends

 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 46 -------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.h |  2 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c     |  4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c     | 55 +++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 75 ---------------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  1 -
 drivers/gpu/drm/nouveau/nouveau_bo.c        | 10 ---
 drivers/gpu/drm/nouveau/nouveau_drm.c       |  3 +-
 drivers/gpu/drm/nouveau/nouveau_gem.c       | 36 ++++++++++
 drivers/gpu/drm/nouveau/nouveau_ttm.c       | 49 --------------
 drivers/gpu/drm/nouveau/nouveau_ttm.h       |  1 -
 drivers/gpu/drm/radeon/radeon_drv.c         |  3 +-
 drivers/gpu/drm/radeon/radeon_gem.c         | 49 ++++++++++++++
 drivers/gpu/drm/radeon/radeon_ttm.c         | 65 ------------------
 drivers/gpu/drm/radeon/radeon_ttm.h         |  1 -
 drivers/gpu/drm/ttm/ttm_bo_vm.c             | 60 ++---------------
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c  |  9 ---
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c    | 53 ++++++++++++++-
 include/drm/ttm/ttm_bo_api.h                | 13 ----
 include/drm/ttm/ttm_device.h                | 15 -----
 20 files changed, 202 insertions(+), 348 deletions(-)


base-commit: 28dddc0c90bc6464be4c5e3224a293c022564a4e
prerequisite-patch-id: c2b2f08f0eccc9f5df0c0da49fa1d36267deb11d
prerequisite-patch-id: c67e5d886a47b7d0266d81100837557fda34cb24
--
2.31.1

Comments

Thomas Zimmermann May 25, 2021, 3:14 p.m. UTC | #1
Something I forgot to add is that patches 1 to 4 already have a

   Reviewed-by: Christian König <christian.koenig@amd.com>



Am 25.05.21 um 17:10 schrieb Thomas Zimmermann:
> Implement mmap via struct drm_gem_object_functions.mmap in amdgpu,
> radeon and nouveau. This allows for using common DRM helpers for
> the mmap-related callbacks in struct file_operations and struct
> drm_driver. The drivers have their own vm_ops, which are now set
> automatically by the DRM core functions. The code in each driver's
> verify_access becomes part of the driver's new mmap implementation.
> 
> With the GEM drivers converted, vmwgfx is the only user of
> ttm_bo_mmap() and related infrastructure. So move everything into
> vmwgfx and delete the rsp code from TTM.
> 
> This touches several drivers. Preferably everything would be merged
> at once via drm-misc-next.
> 
> v4:
> 	* rebase on top of amdgpu hot-unplug changes
> v3:
> 	* tidy up the new mmap functions in amdgpu and radeon (Christian)
> v2:
> 	* removal of amdgpu fbdev mmap already merged (Christian)
> 	* rebase on top of amdgpu fixes [1] (Felix)
> 	* replace pr_err() with drm_err() in vmwgfx patch (Zack)
> 	* several typos
> 
> [1] https://patchwork.freedesktop.org/series/88822/
> 
> Thomas Zimmermann (7):
>    drm/ttm: Don't override vm_ops callbacks, if set
>    drm/amdgpu: Implement mmap as GEM object function
>    drm/radeon: Implement mmap as GEM object function
>    drm/nouveau: Implement mmap as GEM object function
>    drm/vmwgfx: Inline ttm_bo_mmap() into vmwgfx driver
>    drm/vmwgfx: Inline vmw_verify_access()
>    drm/ttm: Remove ttm_bo_mmap() and friends
> 
>   drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 46 -------------
>   drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.h |  2 -
>   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c     |  4 +-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c     | 55 +++++++++++++++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 75 ---------------------
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  1 -
>   drivers/gpu/drm/nouveau/nouveau_bo.c        | 10 ---
>   drivers/gpu/drm/nouveau/nouveau_drm.c       |  3 +-
>   drivers/gpu/drm/nouveau/nouveau_gem.c       | 36 ++++++++++
>   drivers/gpu/drm/nouveau/nouveau_ttm.c       | 49 --------------
>   drivers/gpu/drm/nouveau/nouveau_ttm.h       |  1 -
>   drivers/gpu/drm/radeon/radeon_drv.c         |  3 +-
>   drivers/gpu/drm/radeon/radeon_gem.c         | 49 ++++++++++++++
>   drivers/gpu/drm/radeon/radeon_ttm.c         | 65 ------------------
>   drivers/gpu/drm/radeon/radeon_ttm.h         |  1 -
>   drivers/gpu/drm/ttm/ttm_bo_vm.c             | 60 ++---------------
>   drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c  |  9 ---
>   drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c    | 53 ++++++++++++++-
>   include/drm/ttm/ttm_bo_api.h                | 13 ----
>   include/drm/ttm/ttm_device.h                | 15 -----
>   20 files changed, 202 insertions(+), 348 deletions(-)
> 
> 
> base-commit: 28dddc0c90bc6464be4c5e3224a293c022564a4e
> prerequisite-patch-id: c2b2f08f0eccc9f5df0c0da49fa1d36267deb11d
> prerequisite-patch-id: c67e5d886a47b7d0266d81100837557fda34cb24
> --
> 2.31.1
>
Christian König May 26, 2021, 11:59 a.m. UTC | #2
Patches #1-#4 are Reviewed-by: Christian König <christian.koenig@amd.com>

Patches #5 and #6 are Acked-by: Christian König <christian.koenig@amd.com>

Patch #7 already has my rb.

I would say push that to drm-misc-next ASAP.

Regards,
Christian.

Am 25.05.21 um 17:10 schrieb Thomas Zimmermann:
> Implement mmap via struct drm_gem_object_functions.mmap in amdgpu,
> radeon and nouveau. This allows for using common DRM helpers for
> the mmap-related callbacks in struct file_operations and struct
> drm_driver. The drivers have their own vm_ops, which are now set
> automatically by the DRM core functions. The code in each driver's
> verify_access becomes part of the driver's new mmap implementation.
>
> With the GEM drivers converted, vmwgfx is the only user of
> ttm_bo_mmap() and related infrastructure. So move everything into
> vmwgfx and delete the rsp code from TTM.
>
> This touches several drivers. Preferably everything would be merged
> at once via drm-misc-next.
>
> v4:
> 	* rebase on top of amdgpu hot-unplug changes
> v3:
> 	* tidy up the new mmap functions in amdgpu and radeon (Christian)
> v2:
> 	* removal of amdgpu fbdev mmap already merged (Christian)
> 	* rebase on top of amdgpu fixes [1] (Felix)
> 	* replace pr_err() with drm_err() in vmwgfx patch (Zack)
> 	* several typos
>
> [1] https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.freedesktop.org%2Fseries%2F88822%2F&amp;data=04%7C01%7Cchristian.koenig%40amd.com%7C782d195c5e8e4ca6351b08d91f8f4e90%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637575522662233381%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=ZJ%2BIx9hFBXzQubYpEKcOngREtjjMKwaChyIonKSACFY%3D&amp;reserved=0
>
> Thomas Zimmermann (7):
>    drm/ttm: Don't override vm_ops callbacks, if set
>    drm/amdgpu: Implement mmap as GEM object function
>    drm/radeon: Implement mmap as GEM object function
>    drm/nouveau: Implement mmap as GEM object function
>    drm/vmwgfx: Inline ttm_bo_mmap() into vmwgfx driver
>    drm/vmwgfx: Inline vmw_verify_access()
>    drm/ttm: Remove ttm_bo_mmap() and friends
>
>   drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 46 -------------
>   drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.h |  2 -
>   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c     |  4 +-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c     | 55 +++++++++++++++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 75 ---------------------
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  1 -
>   drivers/gpu/drm/nouveau/nouveau_bo.c        | 10 ---
>   drivers/gpu/drm/nouveau/nouveau_drm.c       |  3 +-
>   drivers/gpu/drm/nouveau/nouveau_gem.c       | 36 ++++++++++
>   drivers/gpu/drm/nouveau/nouveau_ttm.c       | 49 --------------
>   drivers/gpu/drm/nouveau/nouveau_ttm.h       |  1 -
>   drivers/gpu/drm/radeon/radeon_drv.c         |  3 +-
>   drivers/gpu/drm/radeon/radeon_gem.c         | 49 ++++++++++++++
>   drivers/gpu/drm/radeon/radeon_ttm.c         | 65 ------------------
>   drivers/gpu/drm/radeon/radeon_ttm.h         |  1 -
>   drivers/gpu/drm/ttm/ttm_bo_vm.c             | 60 ++---------------
>   drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c  |  9 ---
>   drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c    | 53 ++++++++++++++-
>   include/drm/ttm/ttm_bo_api.h                | 13 ----
>   include/drm/ttm/ttm_device.h                | 15 -----
>   20 files changed, 202 insertions(+), 348 deletions(-)
>
>
> base-commit: 28dddc0c90bc6464be4c5e3224a293c022564a4e
> prerequisite-patch-id: c2b2f08f0eccc9f5df0c0da49fa1d36267deb11d
> prerequisite-patch-id: c67e5d886a47b7d0266d81100837557fda34cb24
> --
> 2.31.1
>