Re: [2/2] drm: Remove struct drm_driver.gem_prime_mmap

2023-06-14 Thread Thomas Zimmermann

Hi

Am 14.06.23 um 10:26 schrieb Sui Jingfeng:

Hi,

On 2023/6/14 13:34, Thomas Zimmermann wrote:

Hi

Am 14.06.23 um 04:06 schrieb Sui Jingfeng:


On 2023/6/14 01:27, Sui Jingfeng wrote:

Wow, so many drivers get nuked!

On 2023/6/13 22:51, Thomas Zimmermann wrote:

All drivers initialize this field with drm_gem_prime_mmap(). Call
the function directly and remove the field. Simplifies the code and
resolves a long-standing TODO item.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Alex Deucher 



I have tested this patch briefly with drm/amdgpu(RX560), Running 
glmark2, the rendered scene looks OK.


But single driver is self-sharing.  I think I should test this more 
with multiple video card.



No need to test; it's equivalent to removing a wrapper.


Yes, only msm hardware might be affected.



But new DRM (un-upstreamed) drivers cannot be compiled anymore with 
this patch applied.


This makes them all out-of-date or going to be outdated; this is 
embarrassing!


What do you mean by embarrassing? Simply rebase your driver onto the 
change and that's it. This happens regularly for out-of-tree drivers. 
But if such a driver would land before this patchset, I'd have to 
update the patchset instead.



Thanks for you told me this then.

I worry about what it will happen if two conflict patch got merged 
together.


Yes that occasionaly breaks something, but luckily it rarely results in 
a significant problem.  Drivers that break can be disabled by the 
majority of developers. So that's not an issue for most.  Core code is a 
bit more important. Usually someone provides a patch or workaround quickly.


Best regards
Thomas



If my driver got merged, then one more driver will be nuked together. 
Saving a lot of effort.




Best regards
Thomas






---
  Documentation/gpu/todo.rst  |  9 -
  drivers/accel/ivpu/ivpu_drv.c   |  1 -
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  1 -
  drivers/gpu/drm/drm_fbdev_dma.c |  6 +-
  drivers/gpu/drm/drm_prime.c | 14 ++
  drivers/gpu/drm/etnaviv/etnaviv_drv.c   |  1 -
  drivers/gpu/drm/exynos/exynos_drm_drv.c |  1 -
  drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c |  1 -
  drivers/gpu/drm/lima/lima_drv.c |  1 -
  drivers/gpu/drm/mediatek/mtk_drm_drv.c  |  1 -
  drivers/gpu/drm/msm/msm_drv.c   |  1 -
  drivers/gpu/drm/msm/msm_drv.h   |  1 -
  drivers/gpu/drm/msm/msm_gem_prime.c |  5 -
  drivers/gpu/drm/nouveau/nouveau_drm.c   |  1 -
  drivers/gpu/drm/panfrost/panfrost_drv.c |  1 -
  drivers/gpu/drm/pl111/pl111_drv.c   |  1 -
  drivers/gpu/drm/radeon/radeon_drv.c |  1 -
  drivers/gpu/drm/renesas/rcar-du/rcar_du_drv.c   |  1 -
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |  1 -
  drivers/gpu/drm/v3d/v3d_drv.c   |  1 -
  drivers/gpu/drm/virtio/virtgpu_drv.c    |  1 -
  drivers/gpu/drm/xen/xen_drm_front.c |  1 -
  include/drm/drm_drv.h   | 14 --
  include/drm/drm_gem_dma_helper.h    |  6 ++
  include/drm/drm_gem_shmem_helper.h  |  1 -
  include/drm/drm_gem_vram_helper.h   |  1 -
  26 files changed, 5 insertions(+), 69 deletions(-)

diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 68bdafa0284f5..ca1efad8c89c3 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -319,15 +319,6 @@ Contact: Daniel Vetter, Noralf Tronnes
    Level: Advanced
  -struct drm_gem_object_funcs

-
-GEM objects can now have a function table instead of having the 
callbacks on the
-DRM driver struct. This is now the preferred way. Callbacks in 
drivers have been

-converted, except for struct drm_driver.gem_prime_mmap.
-
-Level: Intermediate
-
  connector register/unregister fixes
  ---
  diff --git a/drivers/accel/ivpu/ivpu_drv.c 
b/drivers/accel/ivpu/ivpu_drv.c

index 2df7643b843d5..9f2b9fdcc5498 100644
--- a/drivers/accel/ivpu/ivpu_drv.c
+++ b/drivers/accel/ivpu/ivpu_drv.c
@@ -376,7 +376,6 @@ static const struct drm_driver driver = {
  .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
  .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
  .gem_prime_import = ivpu_gem_prime_import,
-    .gem_prime_mmap = drm_gem_prime_mmap,
    .ioctls = ivpu_drm_ioctls,
  .num_ioctls = ARRAY_SIZE(ivpu_drm_ioctls),
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

index c9a41c997c6c7..7681f79f462eb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2809,7 +2809,6 @@ static const struct drm_driver 
amdgpu_kms_driver = {

  .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
  .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
  .gem_prime_import 

Re: [2/2] drm: Remove struct drm_driver.gem_prime_mmap

2023-06-14 Thread Sui Jingfeng

Hi,

On 2023/6/14 13:34, Thomas Zimmermann wrote:

Hi

Am 14.06.23 um 04:06 schrieb Sui Jingfeng:


On 2023/6/14 01:27, Sui Jingfeng wrote:

Wow, so many drivers get nuked!

On 2023/6/13 22:51, Thomas Zimmermann wrote:

All drivers initialize this field with drm_gem_prime_mmap(). Call
the function directly and remove the field. Simplifies the code and
resolves a long-standing TODO item.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Alex Deucher 



I have tested this patch briefly with drm/amdgpu(RX560), Running 
glmark2, the rendered scene looks OK.


But single driver is self-sharing.  I think I should test this more 
with multiple video card.



No need to test; it's equivalent to removing a wrapper.


Yes, only msm hardware might be affected.



But new DRM (un-upstreamed) drivers cannot be compiled anymore with 
this patch applied.


This makes them all out-of-date or going to be outdated; this is 
embarrassing!


What do you mean by embarrassing? Simply rebase your driver onto the 
change and that's it. This happens regularly for out-of-tree drivers. 
But if such a driver would land before this patchset, I'd have to 
update the patchset instead.



Thanks for you told me this then.

I worry about what it will happen if two conflict patch got merged together.

If my driver got merged, then one more driver will be nuked together. 
Saving a lot of effort.




Best regards
Thomas






---
  Documentation/gpu/todo.rst  |  9 -
  drivers/accel/ivpu/ivpu_drv.c   |  1 -
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  1 -
  drivers/gpu/drm/drm_fbdev_dma.c |  6 +-
  drivers/gpu/drm/drm_prime.c | 14 ++
  drivers/gpu/drm/etnaviv/etnaviv_drv.c   |  1 -
  drivers/gpu/drm/exynos/exynos_drm_drv.c |  1 -
  drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c |  1 -
  drivers/gpu/drm/lima/lima_drv.c |  1 -
  drivers/gpu/drm/mediatek/mtk_drm_drv.c  |  1 -
  drivers/gpu/drm/msm/msm_drv.c   |  1 -
  drivers/gpu/drm/msm/msm_drv.h   |  1 -
  drivers/gpu/drm/msm/msm_gem_prime.c |  5 -
  drivers/gpu/drm/nouveau/nouveau_drm.c   |  1 -
  drivers/gpu/drm/panfrost/panfrost_drv.c |  1 -
  drivers/gpu/drm/pl111/pl111_drv.c   |  1 -
  drivers/gpu/drm/radeon/radeon_drv.c |  1 -
  drivers/gpu/drm/renesas/rcar-du/rcar_du_drv.c   |  1 -
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |  1 -
  drivers/gpu/drm/v3d/v3d_drv.c   |  1 -
  drivers/gpu/drm/virtio/virtgpu_drv.c    |  1 -
  drivers/gpu/drm/xen/xen_drm_front.c |  1 -
  include/drm/drm_drv.h   | 14 --
  include/drm/drm_gem_dma_helper.h    |  6 ++
  include/drm/drm_gem_shmem_helper.h  |  1 -
  include/drm/drm_gem_vram_helper.h   |  1 -
  26 files changed, 5 insertions(+), 69 deletions(-)

diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 68bdafa0284f5..ca1efad8c89c3 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -319,15 +319,6 @@ Contact: Daniel Vetter, Noralf Tronnes
    Level: Advanced
  -struct drm_gem_object_funcs

-
-GEM objects can now have a function table instead of having the 
callbacks on the
-DRM driver struct. This is now the preferred way. Callbacks in 
drivers have been

-converted, except for struct drm_driver.gem_prime_mmap.
-
-Level: Intermediate
-
  connector register/unregister fixes
  ---
  diff --git a/drivers/accel/ivpu/ivpu_drv.c 
b/drivers/accel/ivpu/ivpu_drv.c

index 2df7643b843d5..9f2b9fdcc5498 100644
--- a/drivers/accel/ivpu/ivpu_drv.c
+++ b/drivers/accel/ivpu/ivpu_drv.c
@@ -376,7 +376,6 @@ static const struct drm_driver driver = {
  .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
  .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
  .gem_prime_import = ivpu_gem_prime_import,
-    .gem_prime_mmap = drm_gem_prime_mmap,
    .ioctls = ivpu_drm_ioctls,
  .num_ioctls = ARRAY_SIZE(ivpu_drm_ioctls),
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

index c9a41c997c6c7..7681f79f462eb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2809,7 +2809,6 @@ static const struct drm_driver 
amdgpu_kms_driver = {

  .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
  .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
  .gem_prime_import = amdgpu_gem_prime_import,
-    .gem_prime_mmap = drm_gem_prime_mmap,
    .name = DRIVER_NAME,
  .desc = DRIVER_DESC,
diff --git a/drivers/gpu/drm/drm_fbdev_dma.c 
b/drivers/gpu/drm/drm_fbdev_dma.c

index d86773fa8ab00..8217f1ddc0075 100644
--- a/drivers/gpu/drm/drm_fbdev_dma.c
+++ b/drivers/gpu/drm/drm_fbdev_dma.c
@@ -54,12 +54,8 @@ static void 

Re: [2/2] drm: Remove struct drm_driver.gem_prime_mmap

2023-06-13 Thread Thomas Zimmermann

Hi

Am 14.06.23 um 04:06 schrieb Sui Jingfeng:


On 2023/6/14 01:27, Sui Jingfeng wrote:

Wow, so many drivers get nuked!

On 2023/6/13 22:51, Thomas Zimmermann wrote:

All drivers initialize this field with drm_gem_prime_mmap(). Call
the function directly and remove the field. Simplifies the code and
resolves a long-standing TODO item.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Alex Deucher 



I have tested this patch briefly with drm/amdgpu(RX560), Running 
glmark2, the rendered scene looks OK.


But single driver is self-sharing.  I think I should test this more 
with multiple video card.



No need to test; it's equivalent to removing a wrapper.


Yes, only msm hardware might be affected.



But new DRM (un-upstreamed) drivers cannot be compiled anymore with this 
patch applied.


This makes them all out-of-date or going to be outdated; this is 
embarrassing!


What do you mean by embarrassing? Simply rebase your driver onto the 
change and that's it. This happens regularly for out-of-tree drivers. 
But if such a driver would land before this patchset, I'd have to update 
the patchset instead.


Best regards
Thomas






---
  Documentation/gpu/todo.rst  |  9 -
  drivers/accel/ivpu/ivpu_drv.c   |  1 -
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  1 -
  drivers/gpu/drm/drm_fbdev_dma.c |  6 +-
  drivers/gpu/drm/drm_prime.c | 14 ++
  drivers/gpu/drm/etnaviv/etnaviv_drv.c   |  1 -
  drivers/gpu/drm/exynos/exynos_drm_drv.c |  1 -
  drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c |  1 -
  drivers/gpu/drm/lima/lima_drv.c |  1 -
  drivers/gpu/drm/mediatek/mtk_drm_drv.c  |  1 -
  drivers/gpu/drm/msm/msm_drv.c   |  1 -
  drivers/gpu/drm/msm/msm_drv.h   |  1 -
  drivers/gpu/drm/msm/msm_gem_prime.c |  5 -
  drivers/gpu/drm/nouveau/nouveau_drm.c   |  1 -
  drivers/gpu/drm/panfrost/panfrost_drv.c |  1 -
  drivers/gpu/drm/pl111/pl111_drv.c   |  1 -
  drivers/gpu/drm/radeon/radeon_drv.c |  1 -
  drivers/gpu/drm/renesas/rcar-du/rcar_du_drv.c   |  1 -
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |  1 -
  drivers/gpu/drm/v3d/v3d_drv.c   |  1 -
  drivers/gpu/drm/virtio/virtgpu_drv.c    |  1 -
  drivers/gpu/drm/xen/xen_drm_front.c |  1 -
  include/drm/drm_drv.h   | 14 --
  include/drm/drm_gem_dma_helper.h    |  6 ++
  include/drm/drm_gem_shmem_helper.h  |  1 -
  include/drm/drm_gem_vram_helper.h   |  1 -
  26 files changed, 5 insertions(+), 69 deletions(-)

diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 68bdafa0284f5..ca1efad8c89c3 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -319,15 +319,6 @@ Contact: Daniel Vetter, Noralf Tronnes
    Level: Advanced
  -struct drm_gem_object_funcs

-
-GEM objects can now have a function table instead of having the 
callbacks on the
-DRM driver struct. This is now the preferred way. Callbacks in 
drivers have been

-converted, except for struct drm_driver.gem_prime_mmap.
-
-Level: Intermediate
-
  connector register/unregister fixes
  ---
  diff --git a/drivers/accel/ivpu/ivpu_drv.c 
b/drivers/accel/ivpu/ivpu_drv.c

index 2df7643b843d5..9f2b9fdcc5498 100644
--- a/drivers/accel/ivpu/ivpu_drv.c
+++ b/drivers/accel/ivpu/ivpu_drv.c
@@ -376,7 +376,6 @@ static const struct drm_driver driver = {
  .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
  .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
  .gem_prime_import = ivpu_gem_prime_import,
-    .gem_prime_mmap = drm_gem_prime_mmap,
    .ioctls = ivpu_drm_ioctls,
  .num_ioctls = ARRAY_SIZE(ivpu_drm_ioctls),
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

index c9a41c997c6c7..7681f79f462eb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2809,7 +2809,6 @@ static const struct drm_driver 
amdgpu_kms_driver = {

  .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
  .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
  .gem_prime_import = amdgpu_gem_prime_import,
-    .gem_prime_mmap = drm_gem_prime_mmap,
    .name = DRIVER_NAME,
  .desc = DRIVER_DESC,
diff --git a/drivers/gpu/drm/drm_fbdev_dma.c 
b/drivers/gpu/drm/drm_fbdev_dma.c

index d86773fa8ab00..8217f1ddc0075 100644
--- a/drivers/gpu/drm/drm_fbdev_dma.c
+++ b/drivers/gpu/drm/drm_fbdev_dma.c
@@ -54,12 +54,8 @@ static void drm_fbdev_dma_fb_destroy(struct 
fb_info *info)
  static int drm_fbdev_dma_fb_mmap(struct fb_info *info, struct 
vm_area_struct *vma)

  {
  struct drm_fb_helper *fb_helper = info->par;
-    struct drm_device *dev = fb_helper->dev;
-
-    if (drm_WARN_ON_ONCE(dev, 

Re: [2/2] drm: Remove struct drm_driver.gem_prime_mmap

2023-06-13 Thread Sui Jingfeng



On 2023/6/14 01:27, Sui Jingfeng wrote:

Wow, so many drivers get nuked!

On 2023/6/13 22:51, Thomas Zimmermann wrote:

All drivers initialize this field with drm_gem_prime_mmap(). Call
the function directly and remove the field. Simplifies the code and
resolves a long-standing TODO item.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Alex Deucher 



I have tested this patch briefly with drm/amdgpu(RX560), Running 
glmark2, the rendered scene looks OK.


But single driver is self-sharing.  I think I should test this more 
with multiple video card.



No need to test; it's equivalent to removing a wrapper.

But new DRM (un-upstreamed) drivers cannot be compiled anymore with this 
patch applied.


This makes them all out-of-date or going to be outdated; this is 
embarrassing!





---
  Documentation/gpu/todo.rst  |  9 -
  drivers/accel/ivpu/ivpu_drv.c   |  1 -
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  1 -
  drivers/gpu/drm/drm_fbdev_dma.c |  6 +-
  drivers/gpu/drm/drm_prime.c | 14 ++
  drivers/gpu/drm/etnaviv/etnaviv_drv.c   |  1 -
  drivers/gpu/drm/exynos/exynos_drm_drv.c |  1 -
  drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c |  1 -
  drivers/gpu/drm/lima/lima_drv.c |  1 -
  drivers/gpu/drm/mediatek/mtk_drm_drv.c  |  1 -
  drivers/gpu/drm/msm/msm_drv.c   |  1 -
  drivers/gpu/drm/msm/msm_drv.h   |  1 -
  drivers/gpu/drm/msm/msm_gem_prime.c |  5 -
  drivers/gpu/drm/nouveau/nouveau_drm.c   |  1 -
  drivers/gpu/drm/panfrost/panfrost_drv.c |  1 -
  drivers/gpu/drm/pl111/pl111_drv.c   |  1 -
  drivers/gpu/drm/radeon/radeon_drv.c |  1 -
  drivers/gpu/drm/renesas/rcar-du/rcar_du_drv.c   |  1 -
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |  1 -
  drivers/gpu/drm/v3d/v3d_drv.c   |  1 -
  drivers/gpu/drm/virtio/virtgpu_drv.c    |  1 -
  drivers/gpu/drm/xen/xen_drm_front.c |  1 -
  include/drm/drm_drv.h   | 14 --
  include/drm/drm_gem_dma_helper.h    |  6 ++
  include/drm/drm_gem_shmem_helper.h  |  1 -
  include/drm/drm_gem_vram_helper.h   |  1 -
  26 files changed, 5 insertions(+), 69 deletions(-)

diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 68bdafa0284f5..ca1efad8c89c3 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -319,15 +319,6 @@ Contact: Daniel Vetter, Noralf Tronnes
    Level: Advanced
  -struct drm_gem_object_funcs

-
-GEM objects can now have a function table instead of having the 
callbacks on the
-DRM driver struct. This is now the preferred way. Callbacks in 
drivers have been

-converted, except for struct drm_driver.gem_prime_mmap.
-
-Level: Intermediate
-
  connector register/unregister fixes
  ---
  diff --git a/drivers/accel/ivpu/ivpu_drv.c 
b/drivers/accel/ivpu/ivpu_drv.c

index 2df7643b843d5..9f2b9fdcc5498 100644
--- a/drivers/accel/ivpu/ivpu_drv.c
+++ b/drivers/accel/ivpu/ivpu_drv.c
@@ -376,7 +376,6 @@ static const struct drm_driver driver = {
  .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
  .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
  .gem_prime_import = ivpu_gem_prime_import,
-    .gem_prime_mmap = drm_gem_prime_mmap,
    .ioctls = ivpu_drm_ioctls,
  .num_ioctls = ARRAY_SIZE(ivpu_drm_ioctls),
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

index c9a41c997c6c7..7681f79f462eb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2809,7 +2809,6 @@ static const struct drm_driver 
amdgpu_kms_driver = {

  .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
  .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
  .gem_prime_import = amdgpu_gem_prime_import,
-    .gem_prime_mmap = drm_gem_prime_mmap,
    .name = DRIVER_NAME,
  .desc = DRIVER_DESC,
diff --git a/drivers/gpu/drm/drm_fbdev_dma.c 
b/drivers/gpu/drm/drm_fbdev_dma.c

index d86773fa8ab00..8217f1ddc0075 100644
--- a/drivers/gpu/drm/drm_fbdev_dma.c
+++ b/drivers/gpu/drm/drm_fbdev_dma.c
@@ -54,12 +54,8 @@ static void drm_fbdev_dma_fb_destroy(struct 
fb_info *info)
  static int drm_fbdev_dma_fb_mmap(struct fb_info *info, struct 
vm_area_struct *vma)

  {
  struct drm_fb_helper *fb_helper = info->par;
-    struct drm_device *dev = fb_helper->dev;
-
-    if (drm_WARN_ON_ONCE(dev, !fb_helper->dev->driver->gem_prime_mmap))
-    return -ENODEV;
  -    return 
fb_helper->dev->driver->gem_prime_mmap(fb_helper->buffer->gem, vma);

+    return drm_gem_prime_mmap(fb_helper->buffer->gem, vma);
  }
    static const struct fb_ops drm_fbdev_dma_fb_ops = {
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 

Re: [2/2] drm: Remove struct drm_driver.gem_prime_mmap

2023-06-13 Thread Sui Jingfeng

Wow, so many drivers get nuked!

On 2023/6/13 22:51, Thomas Zimmermann wrote:

All drivers initialize this field with drm_gem_prime_mmap(). Call
the function directly and remove the field. Simplifies the code and
resolves a long-standing TODO item.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Alex Deucher 



I have tested this patch briefly with drm/amdgpu(RX560), Running 
glmark2, the rendered scene looks OK.


But single driver is self-sharing.  I think I should test this more with 
multiple video card.




---
  Documentation/gpu/todo.rst  |  9 -
  drivers/accel/ivpu/ivpu_drv.c   |  1 -
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  1 -
  drivers/gpu/drm/drm_fbdev_dma.c |  6 +-
  drivers/gpu/drm/drm_prime.c | 14 ++
  drivers/gpu/drm/etnaviv/etnaviv_drv.c   |  1 -
  drivers/gpu/drm/exynos/exynos_drm_drv.c |  1 -
  drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c |  1 -
  drivers/gpu/drm/lima/lima_drv.c |  1 -
  drivers/gpu/drm/mediatek/mtk_drm_drv.c  |  1 -
  drivers/gpu/drm/msm/msm_drv.c   |  1 -
  drivers/gpu/drm/msm/msm_drv.h   |  1 -
  drivers/gpu/drm/msm/msm_gem_prime.c |  5 -
  drivers/gpu/drm/nouveau/nouveau_drm.c   |  1 -
  drivers/gpu/drm/panfrost/panfrost_drv.c |  1 -
  drivers/gpu/drm/pl111/pl111_drv.c   |  1 -
  drivers/gpu/drm/radeon/radeon_drv.c |  1 -
  drivers/gpu/drm/renesas/rcar-du/rcar_du_drv.c   |  1 -
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |  1 -
  drivers/gpu/drm/v3d/v3d_drv.c   |  1 -
  drivers/gpu/drm/virtio/virtgpu_drv.c|  1 -
  drivers/gpu/drm/xen/xen_drm_front.c |  1 -
  include/drm/drm_drv.h   | 14 --
  include/drm/drm_gem_dma_helper.h|  6 ++
  include/drm/drm_gem_shmem_helper.h  |  1 -
  include/drm/drm_gem_vram_helper.h   |  1 -
  26 files changed, 5 insertions(+), 69 deletions(-)

diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 68bdafa0284f5..ca1efad8c89c3 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -319,15 +319,6 @@ Contact: Daniel Vetter, Noralf Tronnes
  
  Level: Advanced
  
-struct drm_gem_object_funcs


-
-GEM objects can now have a function table instead of having the callbacks on 
the
-DRM driver struct. This is now the preferred way. Callbacks in drivers have 
been
-converted, except for struct drm_driver.gem_prime_mmap.
-
-Level: Intermediate
-
  connector register/unregister fixes
  ---
  
diff --git a/drivers/accel/ivpu/ivpu_drv.c b/drivers/accel/ivpu/ivpu_drv.c

index 2df7643b843d5..9f2b9fdcc5498 100644
--- a/drivers/accel/ivpu/ivpu_drv.c
+++ b/drivers/accel/ivpu/ivpu_drv.c
@@ -376,7 +376,6 @@ static const struct drm_driver driver = {
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_import = ivpu_gem_prime_import,
-   .gem_prime_mmap = drm_gem_prime_mmap,
  
  	.ioctls = ivpu_drm_ioctls,

.num_ioctls = ARRAY_SIZE(ivpu_drm_ioctls),
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index c9a41c997c6c7..7681f79f462eb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2809,7 +2809,6 @@ static const struct drm_driver amdgpu_kms_driver = {
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_import = amdgpu_gem_prime_import,
-   .gem_prime_mmap = drm_gem_prime_mmap,
  
  	.name = DRIVER_NAME,

.desc = DRIVER_DESC,
diff --git a/drivers/gpu/drm/drm_fbdev_dma.c b/drivers/gpu/drm/drm_fbdev_dma.c
index d86773fa8ab00..8217f1ddc0075 100644
--- a/drivers/gpu/drm/drm_fbdev_dma.c
+++ b/drivers/gpu/drm/drm_fbdev_dma.c
@@ -54,12 +54,8 @@ static void drm_fbdev_dma_fb_destroy(struct fb_info *info)
  static int drm_fbdev_dma_fb_mmap(struct fb_info *info, struct vm_area_struct 
*vma)
  {
struct drm_fb_helper *fb_helper = info->par;
-   struct drm_device *dev = fb_helper->dev;
-
-   if (drm_WARN_ON_ONCE(dev, !fb_helper->dev->driver->gem_prime_mmap))
-   return -ENODEV;
  
-	return fb_helper->dev->driver->gem_prime_mmap(fb_helper->buffer->gem, vma);

+   return drm_gem_prime_mmap(fb_helper->buffer->gem, vma);
  }
  
  static const struct fb_ops drm_fbdev_dma_fb_ops = {

diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index d29dafce9bb0a..6bcf324ef81c9 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -715,8 +715,6 @@ EXPORT_SYMBOL(drm_gem_dmabuf_vunmap);
   * the same codepath that is used for regular GEM buffer mapping on the DRM 
fd.
   * 

Re: [PATCH 2/2] drm: Remove struct drm_driver.gem_prime_mmap

2023-06-13 Thread Alex Deucher
On Tue, Jun 13, 2023 at 11:05 AM Thomas Zimmermann  wrote:
>
> All drivers initialize this field with drm_gem_prime_mmap(). Call
> the function directly and remove the field. Simplifies the code and
> resolves a long-standing TODO item.
>
> Signed-off-by: Thomas Zimmermann 

Series is:
Reviewed-by: Alex Deucher 

> ---
>  Documentation/gpu/todo.rst  |  9 -
>  drivers/accel/ivpu/ivpu_drv.c   |  1 -
>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  1 -
>  drivers/gpu/drm/drm_fbdev_dma.c |  6 +-
>  drivers/gpu/drm/drm_prime.c | 14 ++
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c   |  1 -
>  drivers/gpu/drm/exynos/exynos_drm_drv.c |  1 -
>  drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c |  1 -
>  drivers/gpu/drm/lima/lima_drv.c |  1 -
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c  |  1 -
>  drivers/gpu/drm/msm/msm_drv.c   |  1 -
>  drivers/gpu/drm/msm/msm_drv.h   |  1 -
>  drivers/gpu/drm/msm/msm_gem_prime.c |  5 -
>  drivers/gpu/drm/nouveau/nouveau_drm.c   |  1 -
>  drivers/gpu/drm/panfrost/panfrost_drv.c |  1 -
>  drivers/gpu/drm/pl111/pl111_drv.c   |  1 -
>  drivers/gpu/drm/radeon/radeon_drv.c |  1 -
>  drivers/gpu/drm/renesas/rcar-du/rcar_du_drv.c   |  1 -
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |  1 -
>  drivers/gpu/drm/v3d/v3d_drv.c   |  1 -
>  drivers/gpu/drm/virtio/virtgpu_drv.c|  1 -
>  drivers/gpu/drm/xen/xen_drm_front.c |  1 -
>  include/drm/drm_drv.h   | 14 --
>  include/drm/drm_gem_dma_helper.h|  6 ++
>  include/drm/drm_gem_shmem_helper.h  |  1 -
>  include/drm/drm_gem_vram_helper.h   |  1 -
>  26 files changed, 5 insertions(+), 69 deletions(-)
>
> diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
> index 68bdafa0284f5..ca1efad8c89c3 100644
> --- a/Documentation/gpu/todo.rst
> +++ b/Documentation/gpu/todo.rst
> @@ -319,15 +319,6 @@ Contact: Daniel Vetter, Noralf Tronnes
>
>  Level: Advanced
>
> -struct drm_gem_object_funcs
> 
> -
> -GEM objects can now have a function table instead of having the callbacks on 
> the
> -DRM driver struct. This is now the preferred way. Callbacks in drivers have 
> been
> -converted, except for struct drm_driver.gem_prime_mmap.
> -
> -Level: Intermediate
> -
>  connector register/unregister fixes
>  ---
>
> diff --git a/drivers/accel/ivpu/ivpu_drv.c b/drivers/accel/ivpu/ivpu_drv.c
> index 2df7643b843d5..9f2b9fdcc5498 100644
> --- a/drivers/accel/ivpu/ivpu_drv.c
> +++ b/drivers/accel/ivpu/ivpu_drv.c
> @@ -376,7 +376,6 @@ static const struct drm_driver driver = {
> .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
> .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
> .gem_prime_import = ivpu_gem_prime_import,
> -   .gem_prime_mmap = drm_gem_prime_mmap,
>
> .ioctls = ivpu_drm_ioctls,
> .num_ioctls = ARRAY_SIZE(ivpu_drm_ioctls),
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index c9a41c997c6c7..7681f79f462eb 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -2809,7 +2809,6 @@ static const struct drm_driver amdgpu_kms_driver = {
> .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
> .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
> .gem_prime_import = amdgpu_gem_prime_import,
> -   .gem_prime_mmap = drm_gem_prime_mmap,
>
> .name = DRIVER_NAME,
> .desc = DRIVER_DESC,
> diff --git a/drivers/gpu/drm/drm_fbdev_dma.c b/drivers/gpu/drm/drm_fbdev_dma.c
> index d86773fa8ab00..8217f1ddc0075 100644
> --- a/drivers/gpu/drm/drm_fbdev_dma.c
> +++ b/drivers/gpu/drm/drm_fbdev_dma.c
> @@ -54,12 +54,8 @@ static void drm_fbdev_dma_fb_destroy(struct fb_info *info)
>  static int drm_fbdev_dma_fb_mmap(struct fb_info *info, struct vm_area_struct 
> *vma)
>  {
> struct drm_fb_helper *fb_helper = info->par;
> -   struct drm_device *dev = fb_helper->dev;
> -
> -   if (drm_WARN_ON_ONCE(dev, !fb_helper->dev->driver->gem_prime_mmap))
> -   return -ENODEV;
>
> -   return fb_helper->dev->driver->gem_prime_mmap(fb_helper->buffer->gem, 
> vma);
> +   return drm_gem_prime_mmap(fb_helper->buffer->gem, vma);
>  }
>
>  static const struct fb_ops drm_fbdev_dma_fb_ops = {
> diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
> index d29dafce9bb0a..6bcf324ef81c9 100644
> --- a/drivers/gpu/drm/drm_prime.c
> +++ b/drivers/gpu/drm/drm_prime.c
> @@ -715,8 +715,6 @@ EXPORT_SYMBOL(drm_gem_dmabuf_vunmap);
>   * the same codepath that is used for regular GEM buffer mapping on the DRM 
> fd.
>   * The fake GEM offset is added to vma->vm_pgoff 

[PATCH 2/2] drm: Remove struct drm_driver.gem_prime_mmap

2023-06-13 Thread Thomas Zimmermann
All drivers initialize this field with drm_gem_prime_mmap(). Call
the function directly and remove the field. Simplifies the code and
resolves a long-standing TODO item.

Signed-off-by: Thomas Zimmermann 
---
 Documentation/gpu/todo.rst  |  9 -
 drivers/accel/ivpu/ivpu_drv.c   |  1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  1 -
 drivers/gpu/drm/drm_fbdev_dma.c |  6 +-
 drivers/gpu/drm/drm_prime.c | 14 ++
 drivers/gpu/drm/etnaviv/etnaviv_drv.c   |  1 -
 drivers/gpu/drm/exynos/exynos_drm_drv.c |  1 -
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c |  1 -
 drivers/gpu/drm/lima/lima_drv.c |  1 -
 drivers/gpu/drm/mediatek/mtk_drm_drv.c  |  1 -
 drivers/gpu/drm/msm/msm_drv.c   |  1 -
 drivers/gpu/drm/msm/msm_drv.h   |  1 -
 drivers/gpu/drm/msm/msm_gem_prime.c |  5 -
 drivers/gpu/drm/nouveau/nouveau_drm.c   |  1 -
 drivers/gpu/drm/panfrost/panfrost_drv.c |  1 -
 drivers/gpu/drm/pl111/pl111_drv.c   |  1 -
 drivers/gpu/drm/radeon/radeon_drv.c |  1 -
 drivers/gpu/drm/renesas/rcar-du/rcar_du_drv.c   |  1 -
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c |  1 -
 drivers/gpu/drm/v3d/v3d_drv.c   |  1 -
 drivers/gpu/drm/virtio/virtgpu_drv.c|  1 -
 drivers/gpu/drm/xen/xen_drm_front.c |  1 -
 include/drm/drm_drv.h   | 14 --
 include/drm/drm_gem_dma_helper.h|  6 ++
 include/drm/drm_gem_shmem_helper.h  |  1 -
 include/drm/drm_gem_vram_helper.h   |  1 -
 26 files changed, 5 insertions(+), 69 deletions(-)

diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 68bdafa0284f5..ca1efad8c89c3 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -319,15 +319,6 @@ Contact: Daniel Vetter, Noralf Tronnes
 
 Level: Advanced
 
-struct drm_gem_object_funcs

-
-GEM objects can now have a function table instead of having the callbacks on 
the
-DRM driver struct. This is now the preferred way. Callbacks in drivers have 
been
-converted, except for struct drm_driver.gem_prime_mmap.
-
-Level: Intermediate
-
 connector register/unregister fixes
 ---
 
diff --git a/drivers/accel/ivpu/ivpu_drv.c b/drivers/accel/ivpu/ivpu_drv.c
index 2df7643b843d5..9f2b9fdcc5498 100644
--- a/drivers/accel/ivpu/ivpu_drv.c
+++ b/drivers/accel/ivpu/ivpu_drv.c
@@ -376,7 +376,6 @@ static const struct drm_driver driver = {
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_import = ivpu_gem_prime_import,
-   .gem_prime_mmap = drm_gem_prime_mmap,
 
.ioctls = ivpu_drm_ioctls,
.num_ioctls = ARRAY_SIZE(ivpu_drm_ioctls),
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index c9a41c997c6c7..7681f79f462eb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2809,7 +2809,6 @@ static const struct drm_driver amdgpu_kms_driver = {
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_import = amdgpu_gem_prime_import,
-   .gem_prime_mmap = drm_gem_prime_mmap,
 
.name = DRIVER_NAME,
.desc = DRIVER_DESC,
diff --git a/drivers/gpu/drm/drm_fbdev_dma.c b/drivers/gpu/drm/drm_fbdev_dma.c
index d86773fa8ab00..8217f1ddc0075 100644
--- a/drivers/gpu/drm/drm_fbdev_dma.c
+++ b/drivers/gpu/drm/drm_fbdev_dma.c
@@ -54,12 +54,8 @@ static void drm_fbdev_dma_fb_destroy(struct fb_info *info)
 static int drm_fbdev_dma_fb_mmap(struct fb_info *info, struct vm_area_struct 
*vma)
 {
struct drm_fb_helper *fb_helper = info->par;
-   struct drm_device *dev = fb_helper->dev;
-
-   if (drm_WARN_ON_ONCE(dev, !fb_helper->dev->driver->gem_prime_mmap))
-   return -ENODEV;
 
-   return fb_helper->dev->driver->gem_prime_mmap(fb_helper->buffer->gem, 
vma);
+   return drm_gem_prime_mmap(fb_helper->buffer->gem, vma);
 }
 
 static const struct fb_ops drm_fbdev_dma_fb_ops = {
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index d29dafce9bb0a..6bcf324ef81c9 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -715,8 +715,6 @@ EXPORT_SYMBOL(drm_gem_dmabuf_vunmap);
  * the same codepath that is used for regular GEM buffer mapping on the DRM fd.
  * The fake GEM offset is added to vma->vm_pgoff and _driver->fops->mmap is
  * called to set up the mapping.
- *
- * Drivers can use this as their _driver.gem_prime_mmap callback.
  */
 int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
 {
@@ -772,25 +770,17 @@ EXPORT_SYMBOL(drm_gem_prime_mmap);
  * @vma: virtual address